소스 검색

Scrutinizer Auto-Fixes

This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
Scrutinizer Auto-Fixer 5 년 전
부모
커밋
444c293c01
100개의 변경된 파일2817개의 추가작업 그리고 2817개의 파일을 삭제
  1. 5 5
      htdocs/accountancy/admin/account.php
  2. 6 6
      htdocs/accountancy/admin/card.php
  3. 19 19
      htdocs/accountancy/admin/closure.php
  4. 6 6
      htdocs/accountancy/admin/fiscalyear_info.php
  5. 20 20
      htdocs/accountancy/bookkeeping/listbyaccount.php
  6. 36 36
      htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php
  7. 40 40
      htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php
  8. 177 177
      htdocs/accountancy/class/accountancycategory.class.php
  9. 13 13
      htdocs/accountancy/class/accountancyexport.class.php
  10. 11 11
      htdocs/accountancy/class/accountancysystem.class.php
  11. 103 103
      htdocs/accountancy/class/accountingaccount.class.php
  12. 7 7
      htdocs/accountancy/class/bookkeeping.class.php
  13. 67 67
      htdocs/accountancy/class/lettering.class.php
  14. 1 1
      htdocs/accountancy/customer/index.php
  15. 4 4
      htdocs/accountancy/customer/list.php
  16. 2 2
      htdocs/accountancy/index.php
  17. 256 256
      htdocs/accountancy/journal/bankjournal.php
  18. 24 24
      htdocs/accountancy/journal/expensereportsjournal.php
  19. 29 29
      htdocs/accountancy/journal/purchasesjournal.php
  20. 34 34
      htdocs/accountancy/journal/sellsjournal.php
  21. 47 47
      htdocs/adherents/admin/adherent.php
  22. 24 24
      htdocs/adherents/admin/adherent_emails.php
  23. 10 10
      htdocs/adherents/admin/adherent_extrafields.php
  24. 11 11
      htdocs/adherents/admin/adherent_type_extrafields.php
  25. 10 10
      htdocs/adherents/admin/website.php
  26. 8 8
      htdocs/adherents/agenda.php
  27. 35 35
      htdocs/adherents/canvas/actions_adherentcard_common.class.php
  28. 11 11
      htdocs/adherents/canvas/default/actions_adherentcard_default.class.php
  29. 3 3
      htdocs/adherents/canvas/default/tpl/adherentcard_create.tpl.php
  30. 2 2
      htdocs/adherents/canvas/default/tpl/adherentcard_edit.tpl.php
  31. 4 4
      htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php
  32. 79 79
      htdocs/adherents/cartes/carte.php
  33. 31 31
      htdocs/adherents/class/adherentstats.class.php
  34. 31 31
      htdocs/adherents/class/api_members.class.php
  35. 24 24
      htdocs/adherents/class/api_memberstypes.class.php
  36. 22 22
      htdocs/adherents/class/api_subscriptions.class.php
  37. 61 61
      htdocs/adherents/class/subscription.class.php
  38. 23 23
      htdocs/adherents/document.php
  39. 10 10
      htdocs/adherents/htpasswd.php
  40. 46 46
      htdocs/adherents/index.php
  41. 20 20
      htdocs/adherents/ldap.php
  42. 11 11
      htdocs/adherents/note.php
  43. 23 23
      htdocs/adherents/stats/byproperties.php
  44. 81 81
      htdocs/adherents/stats/geo.php
  45. 21 21
      htdocs/adherents/stats/index.php
  46. 10 10
      htdocs/adherents/subscription.php
  47. 2 2
      htdocs/adherents/subscription/info.php
  48. 4 4
      htdocs/adherents/type_translation.php
  49. 23 23
      htdocs/admin/accountant.php
  50. 1 1
      htdocs/admin/agenda.php
  51. 11 11
      htdocs/admin/agenda_extrafields.php
  52. 54 54
      htdocs/admin/agenda_extsites.php
  53. 1 1
      htdocs/admin/agenda_other.php
  54. 16 16
      htdocs/admin/agenda_reminder.php
  55. 15 15
      htdocs/admin/barcode.php
  56. 1 1
      htdocs/admin/boxes.php
  57. 36 36
      htdocs/admin/chequereceipts.php
  58. 13 13
      htdocs/admin/clicktodial.php
  59. 9 9
      htdocs/admin/commande_fournisseur_dispatch_extrafields.php
  60. 1 1
      htdocs/admin/company.php
  61. 3 3
      htdocs/admin/compta.php
  62. 5 5
      htdocs/admin/confexped.php
  63. 46 46
      htdocs/admin/const.php
  64. 7 7
      htdocs/admin/debugbar.php
  65. 13 13
      htdocs/admin/delais.php
  66. 3 3
      htdocs/admin/dict.php
  67. 1 1
      htdocs/admin/dolistore/class/dolistore.class.php
  68. 6 6
      htdocs/admin/ecm.php
  69. 5 5
      htdocs/admin/emailcollector_card.php
  70. 1 1
      htdocs/admin/emailcollector_list.php
  71. 66 66
      htdocs/admin/expedition.php
  72. 9 9
      htdocs/admin/expedition_extrafields.php
  73. 9 9
      htdocs/admin/expeditiondet_extrafields.php
  74. 61 61
      htdocs/admin/expensereport.php
  75. 8 8
      htdocs/admin/expensereport_extrafields.php
  76. 6 6
      htdocs/admin/expensereport_ik.php
  77. 44 44
      htdocs/admin/external_rss.php
  78. 13 13
      htdocs/admin/facture_situation.php
  79. 35 35
      htdocs/admin/fckeditor.php
  80. 25 25
      htdocs/admin/geoipmaxmind.php
  81. 8 8
      htdocs/admin/holiday_extrafields.php
  82. 8 8
      htdocs/admin/index.php
  83. 59 59
      htdocs/admin/ldap.php
  84. 54 54
      htdocs/admin/ldap_contacts.php
  85. 58 58
      htdocs/admin/ldap_members.php
  86. 72 72
      htdocs/admin/ldap_users.php
  87. 50 50
      htdocs/admin/limits.php
  88. 9 9
      htdocs/admin/livraison_extrafields.php
  89. 9 9
      htdocs/admin/livraisondet_extrafields.php
  90. 15 15
      htdocs/admin/mailing.php
  91. 32 32
      htdocs/admin/mailman.php
  92. 2 2
      htdocs/admin/mails.php
  93. 88 88
      htdocs/admin/mails_emailing.php
  94. 36 36
      htdocs/admin/menus.php
  95. 5 5
      htdocs/admin/menus/index.php
  96. 3 3
      htdocs/admin/menus/other.php
  97. 175 175
      htdocs/admin/modulehelp.php
  98. 17 17
      htdocs/admin/modules.php
  99. 17 17
      htdocs/admin/openinghours.php
  100. 29 29
      htdocs/admin/payment.php

+ 5 - 5
htdocs/accountancy/admin/account.php

@@ -332,7 +332,7 @@ if ($resql)
     else dol_print_error($db);
     print "</select>";
     print ajax_combobox("chartofaccounts");
-    print '<input type="'.(empty($conf->use_javascript_ajax)?'submit':'button').'" class="button" name="change_chart" id="change_chart" value="'.dol_escape_htmltag($langs->trans("ChangeAndLoad")).'">';
+    print '<input type="'.(empty($conf->use_javascript_ajax) ? 'submit' : 'button').'" class="button" name="change_chart" id="change_chart" value="'.dol_escape_htmltag($langs->trans("ChangeAndLoad")).'">';
 
     print '<br>';
 	print '<br>';
@@ -357,7 +357,7 @@ if ($resql)
 		print '</td>';
 	}
 	if (!empty($arrayfields['aa.pcg_type']['checked']))		    print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_pcgtype" value="'.$search_pcgtype.'"></td>';
-	if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (! empty($arrayfields['aa.reconcilable']['checked']))   print '<td class="liste_titre">&nbsp;</td>'; }
+	if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (!empty($arrayfields['aa.reconcilable']['checked']))   print '<td class="liste_titre">&nbsp;</td>'; }
 	if (!empty($arrayfields['aa.active']['checked']))			print '<td class="liste_titre">&nbsp;</td>';
 	print '<td class="liste_titre maxwidthsearch">';
 	$searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1);
@@ -371,7 +371,7 @@ if ($resql)
 	if (!empty($arrayfields['aa.labelshort']['checked']))		print_liste_field_titre($arrayfields['aa.labelshort']['label'], $_SERVER["PHP_SELF"], "aa.labelshort", "", $param, '', $sortfield, $sortorder);
 	if (!empty($arrayfields['aa.account_parent']['checked']))	print_liste_field_titre($arrayfields['aa.account_parent']['label'], $_SERVER["PHP_SELF"], "aa.account_parent", "", $param, '', $sortfield, $sortorder, 'left ');
 	if (!empty($arrayfields['aa.pcg_type']['checked']))			print_liste_field_titre($arrayfields['aa.pcg_type']['label'], $_SERVER["PHP_SELF"], 'aa.pcg_type', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.pcg_type']['help']);
-	if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (! empty($arrayfields['aa.reconcilable']['checked']))	print_liste_field_titre($arrayfields['aa.reconcilable']['label'], $_SERVER["PHP_SELF"], 'aa.reconcilable', '', $param, '', $sortfield, $sortorder); }
+	if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (!empty($arrayfields['aa.reconcilable']['checked']))	print_liste_field_titre($arrayfields['aa.reconcilable']['label'], $_SERVER["PHP_SELF"], 'aa.reconcilable', '', $param, '', $sortfield, $sortorder); }
 	if (!empty($arrayfields['aa.active']['checked']))			print_liste_field_titre($arrayfields['aa.active']['label'], $_SERVER["PHP_SELF"], 'aa.active', '', $param, '', $sortfield, $sortorder);
 	print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
 	print "</tr>\n";
@@ -453,11 +453,11 @@ if ($resql)
 			if (!empty($arrayfields['aa.reconcilable']['checked'])) {
 				print '<td class="center">';
 				if (empty($obj->reconcilable)) {
-					print '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?id=' . $obj->rowid . '&action=enable&mode=1">';
+					print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=enable&mode=1">';
 					print img_picto($langs->trans("Disabled"), 'switch_off');
 					print '</a>';
 				} else {
-					print '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?id=' . $obj->rowid . '&action=disable&mode=1">';
+					print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=disable&mode=1">';
 					print img_picto($langs->trans("Activated"), 'switch_on');
 					print '</a>';
 				}

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

@@ -237,8 +237,8 @@ if ($action == 'create') {
 	print '<td><input name="label" size="70" value="'.$object->label.'"></td></tr>';
 
 	// Label short
-	print '<tr><td>' . $langs->trans("LabelToShow") . '</td>';
-	print '<td><input name="labelshort" size="70" value="' . $object->labelshort . '"></td></tr>';
+	print '<tr><td>'.$langs->trans("LabelToShow").'</td>';
+	print '<td><input name="labelshort" size="70" value="'.$object->labelshort.'"></td></tr>';
 
 	// Account parent
 	print '<tr><td>'.$langs->trans("Accountparent").'</td>';
@@ -300,8 +300,8 @@ elseif ($id > 0 || $ref) {
 			print '<td><input name="label" size="70" value="'.$object->label.'"</td></tr>';
 
 			// Label short
-			print '<tr><td>' . $langs->trans("LabelToShow") . '</td>';
-			print '<td><input name="labelshort" size="70" value="' . $object->labelshort . '"</td></tr>';
+			print '<tr><td>'.$langs->trans("LabelToShow").'</td>';
+			print '<td><input name="labelshort" size="70" value="'.$object->labelshort.'"</td></tr>';
 
 			// Account parent
 			print '<tr><td>'.$langs->trans("Accountparent").'</td>';
@@ -351,8 +351,8 @@ elseif ($id > 0 || $ref) {
 			print '<td colspan="2">'.$object->label.'</td></tr>';
 
 			// Label to show
-			print '<tr><td class="titlefield">' . $langs->trans("LabelToShow") . '</td>';
-			print '<td colspan="2">' . $object->labelshort . '</td></tr>';
+			print '<tr><td class="titlefield">'.$langs->trans("LabelToShow").'</td>';
+			print '<td colspan="2">'.$object->labelshort.'</td></tr>';
 
 			// Account parent
 			$accp = new AccountingAccount($db);

+ 19 - 19
htdocs/accountancy/admin/closure.php

@@ -23,12 +23,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 . '/core/class/html.formaccounting.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.'/core/class/html.formaccounting.class.php';
 
 // Load translation files required by the page
-$langs->loadLangs(array("compta","admin","accountancy"));
+$langs->loadLangs(array("compta", "admin", "accountancy"));
 
 // Security check
 if (empty($user->rights->accounting->chartofaccount)) {
@@ -38,7 +38,7 @@ if (empty($user->rights->accounting->chartofaccount)) {
 $action = GETPOST('action', 'aZ09');
 
 
-$list_account_main = array (
+$list_account_main = array(
     'ACCOUNTING_RESULT_PROFIT',
     'ACCOUNTING_RESULT_LOSS'
 );
@@ -52,23 +52,23 @@ if ($action == 'update') {
 
     $defaultjournal = GETPOST('ACCOUNTING_CLOSURE_DEFAULT_JOURNAL', 'alpha');
 
-    if (! empty($defaultjournal)) {
-        if (! dolibarr_set_const($db, 'ACCOUNTING_CLOSURE_DEFAULT_JOURNAL', $defaultjournal, 'chaine', 0, '', $conf->entity)) {
-            $error ++;
+    if (!empty($defaultjournal)) {
+        if (!dolibarr_set_const($db, 'ACCOUNTING_CLOSURE_DEFAULT_JOURNAL', $defaultjournal, 'chaine', 0, '', $conf->entity)) {
+            $error++;
         }
     } else {
-        $error ++;
+        $error++;
     }
 
 	foreach ($list_account_main 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');
@@ -91,8 +91,8 @@ print load_fiche_titre($langs->trans('MenuClosureAccounts'), $linkback, 'title_a
 print '<span class="opacitymedium">'.$langs->trans("DefaultClosureDesc").'</span><br>';
 print '<br>';
 
-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">';
 
 // Define main accounts for closure
@@ -102,14 +102,14 @@ foreach ($list_account_main as $key) {
     print '<tr class="oddeven value">';
     // Param
     $label = $langs->trans($key);
-    $keydesc=$key.'_Desc';
+    $keydesc = $key.'_Desc';
 
     $htmltext = $langs->trans($keydesc);
     print '<td class="fieldrequired" width="50%">';
     print $form->textwithpicto($label, $htmltext);
     print '</td>';
     // Value
-    print '<td>';  // Do not force class=right, or it align also the content of the select box
+    print '<td>'; // Do not force class=right, or it align also the content of the select box
     print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1);
     print '</td>';
     print '</tr>';
@@ -117,15 +117,15 @@ foreach ($list_account_main as $key) {
 
 // Journal
 print '<tr class="oddeven">';
-print '<td width="50%">' . $langs->trans("ACCOUNTING_CLOSURE_DEFAULT_JOURNAL") . '</td>';
+print '<td width="50%">'.$langs->trans("ACCOUNTING_CLOSURE_DEFAULT_JOURNAL").'</td>';
 print '<td>';
-$defaultjournal=$conf->global->ACCOUNTING_CLOSURE_DEFAULT_JOURNAL;
+$defaultjournal = $conf->global->ACCOUNTING_CLOSURE_DEFAULT_JOURNAL;
 print $formaccounting->select_journal($defaultjournal, "ACCOUNTING_CLOSURE_DEFAULT_JOURNAL", 9, 1, 0, 0);
 print '</td></tr>';
 
 print "</table>\n";
 
-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>';
 

+ 6 - 6
htdocs/accountancy/admin/fiscalyear_info.php

@@ -22,23 +22,23 @@
  */
 
 require '../../main.inc.php';
-require_once DOL_DOCUMENT_ROOT . '/core/lib/fiscalyear.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.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/lib/functions2.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)
 	accessforbidden();
-if (! $user->rights->accounting->fiscalyear->write)
+if (!$user->rights->accounting->fiscalyear->write)
 	accessforbidden();
 
 $id = GETPOST('id', 'int');
 
 // View
-$title = $langs->trans("Fiscalyear") . " - " . $langs->trans("Info");
+$title = $langs->trans("Fiscalyear")." - ".$langs->trans("Info");
 $helpurl = "";
 llxHeader("", $title, $helpurl);
 

+ 20 - 20
htdocs/accountancy/bookkeeping/listbyaccount.php

@@ -71,9 +71,9 @@ if ($sortorder == "") $sortorder = "ASC";
 if ($sortfield == "") $sortfield = "t.doc_date,t.rowid";
 
 if (empty($search_date_start) && empty($search_date_end) && GETPOSTISSET('search_date_startday') && GETPOSTISSET('search_date_startmonth') && GETPOSTISSET('search_date_starthour')) {
-	$sql = 	"SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear ";
-	$sql.= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."'";
-	$sql.= $db->plimit(1);
+	$sql = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear ";
+	$sql .= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."'";
+	$sql .= $db->plimit(1);
 	$res = $db->query($sql);
 
 	if ($res->num_rows > 0) {
@@ -220,15 +220,15 @@ if ($result < 0) {
 	setEventMessages($object->error, $object->errors, 'errors');
 }
 
-$num=count($object->lines);
+$num = count($object->lines);
 
 
 if ($action == 'delmouv') {
-	$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?mvt_num=' . GETPOST('mvt_num'), $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvtPartial'), 'delmouvconfirm', '', 0, 1);
+	$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?mvt_num='.GETPOST('mvt_num'), $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvtPartial'), 'delmouvconfirm', '', 0, 1);
 	print $formconfirm;
 }
 if ($action == 'delbookkeepingyear') {
-	$form_question = array ();
+	$form_question = array();
 	$delyear = GETPOST('delyear');
 
 	if (empty($delyear)) {
@@ -249,7 +249,7 @@ if ($action == 'delbookkeepingyear') {
 }
 
 
-print '<form method="POST" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '">';
+print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
 print '<input type="hidden" name="token" value="'.newToken().'">';
 print '<input type="hidden" name="action" value="list">';
 if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
@@ -259,11 +259,11 @@ print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
 print '<input type="hidden" name="page" value="'.$page.'">';
 
 
-$newcardbutton.= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param);
-$newcardbutton.= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', './card.php?action=create');
+$newcardbutton .= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param);
+$newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', './card.php?action=create');
 
-if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
-if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
+if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
+if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
 
 print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy', 0, $viewflat.$newcardbutton, '', $limit);
 
@@ -335,7 +335,7 @@ while ($i < min($num, $limit))
 	//if (empty($accountg)) $accountg = '-';
 
 	// Is it a break ?
-	if ($accountg != $displayed_account_number || ! isset($displayed_account_number)) {
+	if ($accountg != $displayed_account_number || !isset($displayed_account_number)) {
 		// Affiche un Sous-Total par compte comptable
 		if (isset($displayed_account_number)) {
 			print '<tr class="liste_total"><td class="right" colspan="5">'.$langs->trans("SubTotal").':</td><td class="nowrap right">'.price($sous_total_debit).'</td><td class="nowrap right">'.price($sous_total_credit).'</td>';
@@ -348,7 +348,7 @@ while ($i < min($num, $limit))
 		$colspan = 9;
 		print "<tr>";
 		print '<td colspan="'.$colspan.'" style="font-weight:bold; border-bottom: 1pt solid black;">';
-		if ($line->numero_compte != "" && $line->numero_compte != '-1') print length_accountg($line->numero_compte) . ' : ' . $object->get_compte_desc($line->numero_compte);
+		if ($line->numero_compte != "" && $line->numero_compte != '-1') print length_accountg($line->numero_compte).' : '.$object->get_compte_desc($line->numero_compte);
 		else print '<span class="error">'.$langs->trans("Unknown").'</span>';
 		print '</td>';
 		print '</tr>';
@@ -373,20 +373,20 @@ while ($i < min($num, $limit))
 
 	// Affiche un lien vers la facture client/fournisseur
 	$doc_ref = preg_replace('/\(.*\)/', '', $line->doc_ref);
-	print strlen(length_accounta($line->subledger_account)) == 0 ? '<td>' . $line->label_operation . '</td>' : '<td>' . $line->label_operation . '<br><span style="font-size:0.8em">(' . length_accounta($line->subledger_account) . ')</span></td>';
+	print strlen(length_accounta($line->subledger_account)) == 0 ? '<td>'.$line->label_operation.'</td>' : '<td>'.$line->label_operation.'<br><span style="font-size:0.8em">('.length_accounta($line->subledger_account).')</span></td>';
 
 
-	print '<td class="nowrap right">' . ($line->debit ? price($line->debit) :''). '</td>';
-	print '<td class="nowrap right">' . ($line->credit ? price($line->credit) : '') . '</td>';
+	print '<td class="nowrap right">'.($line->debit ? price($line->debit) : '').'</td>';
+	print '<td class="nowrap right">'.($line->credit ? price($line->credit) : '').'</td>';
 
 	$accountingjournal = new AccountingJournal($db);
 	$result = $accountingjournal->fetch('', $line->code_journal);
-	$journaltoshow = (($result > 0)?$accountingjournal->getNomUrl(0, 0, 0, '', 0) : $line->code_journal);
-	print '<td class="center">' . $journaltoshow . '</td>';
+	$journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $line->code_journal);
+	print '<td class="center">'.$journaltoshow.'</td>';
 
 	print '<td class="center">';
-	print '<a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num=' . $line->piece_num . '">' . img_edit() . '</a>&nbsp;';
-	print '<a href="' . $_SERVER['PHP_SELF'] . '?action=delmouv&mvt_num=' . $line->piece_num . $param . '&page=' . $page . '">' . img_delete() . '</a>';
+	print '<a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num='.$line->piece_num.'">'.img_edit().'</a>&nbsp;';
+	print '<a href="'.$_SERVER['PHP_SELF'].'?action=delmouv&mvt_num='.$line->piece_num.$param.'&page='.$page.'">'.img_delete().'</a>';
 	print '</td>';
 	print "</tr>\n";
 

+ 36 - 36
htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php

@@ -27,22 +27,22 @@
  * \brief       Tab to manage customer lettering
  */
 require '../../main.inc.php';
-require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
-require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
-require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php';
-require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
-require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
-require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
+require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
+require_once DOL_DOCUMENT_ROOT.'/accountancy/class/lettering.class.php';
+require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
+require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
 
 // Load translation files required by the page
-$langs->loadLangs(array("compta","accountancy"));
+$langs->loadLangs(array("compta", "accountancy"));
 
 $action     = GETPOST('action', 'aZ09');
 $massaction = GETPOST('massaction', 'alpha');
 $show_files = GETPOST('show_files', 'int');
 $confirm    = GETPOST('confirm', 'alpha');
 $toselect   = GETPOST('toselect', 'array');
-$socid      = GETPOST('socid', 'int')?GETPOST('socid', 'int'):GETPOST('id', 'int');
+$socid      = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : GETPOST('id', 'int');
 
 $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
 $sortfield = GETPOST("sortfield", 'alpha');
@@ -139,15 +139,15 @@ dol_fiche_head($head, 'lettering_customer', $langs->trans("ThirdParty"), 0, 'com
 
 $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
 
-dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom');
+dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom');
 
 dol_fiche_end();
 
 $sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, ";
 $sql .= " bk.subledger_account, bk.numero_compte , bk.label_compte, bk.debit, ";
 $sql .= " bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num, bk.lettering_code ";
-$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk";
-$sql .= " WHERE (bk.subledger_account =  '" . $object->code_compta . "' AND bk.numero_compte = '" . $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER . "' )";
+$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as bk";
+$sql .= " WHERE (bk.subledger_account =  '".$object->code_compta."' AND bk.numero_compte = '".$conf->global->ACCOUNTING_ACCOUNT_CUSTOMER."' )";
 
 /*
 if (dol_strlen($search_date_start) || dol_strlen($search_date_end)) {
@@ -155,7 +155,7 @@ if (dol_strlen($search_date_start) || dol_strlen($search_date_end)) {
 }
 */
 
-$sql.= ' AND bk.entity IN ('.getEntity('accountingbookkeeping').')';
+$sql .= ' AND bk.entity IN ('.getEntity('accountingbookkeeping').')';
 $sql .= $db->order($sortfield, $sortorder);
 
 $debit = 0;
@@ -186,8 +186,8 @@ if (!$resql) {
 	exit();
 }
 
-$param='';
-$param.="&socid=".urlencode($socid);
+$param = '';
+$param .= "&socid=".urlencode($socid);
 
 $num = $db->num_rows($resql);
 
@@ -195,10 +195,10 @@ dol_syslog("/accountancy/bookkeeping/thirdparty_lettering_customer.php", LOG_DEB
 if ($resql) {
 	$i = 0;
 
-    $param="&socid=".$socid;
-	print '<form name="add" action="' . $_SERVER["PHP_SELF"] . '?socid=' . $object->id . '" method="POST">';
-    print '<input type="hidden" name="token" value="' . newToken() . '">';
-	print '<input type="hidden" name="socid" value="' . $object->id . '">';
+    $param = "&socid=".$socid;
+	print '<form name="add" action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="POST">';
+    print '<input type="hidden" name="token" value="'.newToken().'">';
+	print '<input type="hidden" name="socid" value="'.$object->id.'">';
 
     $letteringbutton = '<a class="divButAction"><span class="valignmiddle"><input class="butAction" type="submit" value="lettering" name="lettering" id="lettering"></span></a>';
 
@@ -250,33 +250,33 @@ if ($resql) {
 	$solde = 0;
 	$tmp = '';
 
-    while ( $obj = $db->fetch_object($resql) ) {
+    while ($obj = $db->fetch_object($resql)) {
 		if ($tmp != $obj->lettering_code || empty($tmp))						$tmp = $obj->lettering_code;
 		/*if ($tmp != $obj->lettering_code || empty($obj->lettering_code))*/	$solde += ($obj->credit - $obj->debit);
 
 		print '<tr class="oddeven">';
 
 		//print '<td>' . $obj->doc_type . '</td>' . "\n";
-		print '<td class="center">' . dol_print_date($db->jdate($obj->doc_date), 'day') . '</td>';
-		print '<td>' . $obj->doc_ref . '</td>';
-		print '<td>' . $obj->label_compte . '</td>';
-		print '<td class="nowrap right">' . price($obj->debit) . '</td>';
-		print '<td class="nowrap right">' . price($obj->credit) . '</td>';
-		print '<td class="nowrap right">' . price(round($solde, 2)) . '</td>';
+		print '<td class="center">'.dol_print_date($db->jdate($obj->doc_date), 'day').'</td>';
+		print '<td>'.$obj->doc_ref.'</td>';
+		print '<td>'.$obj->label_compte.'</td>';
+		print '<td class="nowrap right">'.price($obj->debit).'</td>';
+		print '<td class="nowrap right">'.price($obj->credit).'</td>';
+		print '<td class="nowrap right">'.price(round($solde, 2)).'</td>';
 
 		// Journal
         $accountingjournal = new AccountingJournal($db);
         $result = $accountingjournal->fetch('', $obj->code_journal);
-        $journaltoshow = (($result > 0)?$accountingjournal->getNomUrl(0, 0, 0, '', 0) : $obj->code_journal);
-        print '<td class="center">' . $journaltoshow . '</td>';
+        $journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $obj->code_journal);
+        print '<td class="center">'.$journaltoshow.'</td>';
 
         if (empty($obj->lettering_code)) {
-            print '<td class="nowrap center"><input type="checkbox" class="flat checkforselect" name="toselect[]" id="toselect[]" value="' . $obj->rowid . '" /></td>';
-            print '<td><a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num=' . $obj->piece_num . '">';
+            print '<td class="nowrap center"><input type="checkbox" class="flat checkforselect" name="toselect[]" id="toselect[]" value="'.$obj->rowid.'" /></td>';
+            print '<td><a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num='.$obj->piece_num.'">';
             print img_edit();
-            print '</a></td>' . "\n";
+            print '</a></td>'."\n";
         } else {
-            print '<td class="center">' . $obj->lettering_code . '</td>';
+            print '<td class="center">'.$obj->lettering_code.'</td>';
             print '<td></td>';
         }
 
@@ -284,16 +284,16 @@ if ($resql) {
 	}
 
 	print '<tr class="oddeven">';
-	print '<td class="right" colspan="3">'.$langs->trans("Total").':</td>' . "\n";
-	print '<td class="nowrap right"><strong>' . price($debit) . '</strong></td>';
-	print '<td class="nowrap right"><strong>' . price($credit) . '</strong></td>';
+	print '<td class="right" colspan="3">'.$langs->trans("Total").':</td>'."\n";
+	print '<td class="nowrap right"><strong>'.price($debit).'</strong></td>';
+	print '<td class="nowrap right"><strong>'.price($credit).'</strong></td>';
 	print '<td colspan="4"></td>';
 	print "</tr>\n";
 
 	print '<tr class="oddeven">';
-	print '<td class="right" colspan="3">'.$langs->trans("Balancing").':</td>' . "\n";
+	print '<td class="right" colspan="3">'.$langs->trans("Balancing").':</td>'."\n";
 	print '<td colspan="2">&nbsp;</td>';
-	print '<td class="nowrap right"><strong>' . price($credit - $debit) . '</strong></td>';
+	print '<td class="nowrap right"><strong>'.price($credit - $debit).'</strong></td>';
 	print '<td colspan="6"></td>';
 	print "</tr>\n";
 

+ 40 - 40
htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php

@@ -26,22 +26,22 @@
  * \brief 		Tab to setup lettering
  */
 require '../../main.inc.php';
-require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
-require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
-require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php';
-require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
-require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
-require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
+require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
+require_once DOL_DOCUMENT_ROOT.'/accountancy/class/lettering.class.php';
+require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
+require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
 
 // Load translation files required by the page
-$langs->loadLangs(array("compta","accountancy"));
+$langs->loadLangs(array("compta", "accountancy"));
 
 $action     = GETPOST('action', 'aZ09');
 $massaction = GETPOST('massaction', 'alpha');
 $show_files = GETPOST('show_files', 'int');
 $confirm    = GETPOST('confirm', 'alpha');
 $toselect   = GETPOST('toselect', 'array');
-$socid      = GETPOST('socid', 'int')?GETPOST('socid', 'int'):GETPOST('id', 'int');
+$socid      = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : GETPOST('id', 'int');
 
 $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
 $sortfield = GETPOST("sortfield", 'alpha');
@@ -67,7 +67,7 @@ $search_doc_ref = GETPOST("search_doc_ref",'alpha');
 
 $lettering = GETPOST('lettering', 'alpha');
 if (!empty($lettering)) {
-	$action=$lettering;
+	$action = $lettering;
 }
 
 /*
@@ -138,20 +138,20 @@ dol_fiche_head($head, 'lettering_supplier', $langs->trans("ThirdParty"), 0, 'com
 
 $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
 
-dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom');
+dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom');
 
 dol_fiche_end();
 
 $sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, ";
 $sql .= " bk.subledger_account, bk.numero_compte , bk.label_compte, bk.debit, ";
 $sql .= " bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num, bk.lettering_code, bk.date_validated ";
-$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk";
-$sql .= " WHERE (bk.subledger_account =  '" . $object->code_compta_fournisseur . "' AND bk.numero_compte = '" . $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER . "' )";
+$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as bk";
+$sql .= " WHERE (bk.subledger_account =  '".$object->code_compta_fournisseur."' AND bk.numero_compte = '".$conf->global->ACCOUNTING_ACCOUNT_SUPPLIER."' )";
 if (dol_strlen($search_date_start) || dol_strlen($search_date_end)) {
 	$sql .= " AND (bk.doc_date BETWEEN '".$db->idate($search_date_start)."' AND  '".$db->idate($search_date_end)."' )";
 }
-$sql.= ' AND bk.entity IN ('.getEntity('accountingbookkeeping').')';
-$sql.= $db->order($sortfield, $sortorder);
+$sql .= ' AND bk.entity IN ('.getEntity('accountingbookkeeping').')';
+$sql .= $db->order($sortfield, $sortorder);
 
 $debit = 0;
 $credit = 0;
@@ -173,17 +173,17 @@ while ($obj = $db->fetch_object($resql)) {
 	$solde += ($obj->credit - $obj->debit);
 }
 
-$sql.= $db->plimit($limit+1, $offset);
+$sql .= $db->plimit($limit + 1, $offset);
 
 dol_syslog("/accountancy/bookkeeping/thirdparty_lettering_supplier.php", LOG_DEBUG);
 $resql = $db->query($sql);
-if (! $resql) {
+if (!$resql) {
 		dol_print_error($db);
 		exit;
 }
 
-$param='';
-$param.="&socid=".urlencode($socid);
+$param = '';
+$param .= "&socid=".urlencode($socid);
 
 $num = $db->num_rows($resql);
 
@@ -193,10 +193,10 @@ if ($resql) {
 	$num = $db->num_rows($resql);
 	$i = 0;
 
-    $param="&socid=".$socid;
-	print '<form name="add" action="'.$_SERVER["PHP_SELF"].'?socid=' . $object->id . '" method="POST">';
-    print '<input type="hidden" name="token" value="' . newToken() . '">';
-	print '<input type="hidden" name="socid" value="' . $object->id . '">';
+    $param = "&socid=".$socid;
+	print '<form name="add" action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="POST">';
+    print '<input type="hidden" name="token" value="'.newToken().'">';
+	print '<input type="hidden" name="socid" value="'.$object->id.'">';
 
     $letteringbutton = '<a class="divButAction"><span class="valignmiddle"><input class="butAction" type="submit" value="lettering" name="lettering" id="lettering"></span></a>';
 
@@ -254,26 +254,26 @@ if ($resql) {
 		print '<tr class="oddeven">';
 
 		//print '<td>' . $obj->doc_type . '</td>' . "\n";
-		print '<td class="center">' . dol_print_date($db->jdate($obj->doc_date), 'day') . '</td>';
-		print '<td>' . $obj->doc_ref . '</td>';
-		print '<td>' . $obj->label_compte . '</td>';
-		print '<td class="nowrap right">' . price($obj->debit) . '</td>';
-		print '<td class="nowrap right">' . price($obj->credit) . '</td>';
-		print '<td class="nowrap right">' . price(round($solde, 2)) . '</td>';
+		print '<td class="center">'.dol_print_date($db->jdate($obj->doc_date), 'day').'</td>';
+		print '<td>'.$obj->doc_ref.'</td>';
+		print '<td>'.$obj->label_compte.'</td>';
+		print '<td class="nowrap right">'.price($obj->debit).'</td>';
+		print '<td class="nowrap right">'.price($obj->credit).'</td>';
+		print '<td class="nowrap right">'.price(round($solde, 2)).'</td>';
 
         // Journal
         $accountingjournal = new AccountingJournal($db);
         $result = $accountingjournal->fetch('', $obj->code_journal);
-        $journaltoshow = (($result > 0)?$accountingjournal->getNomUrl(0, 0, 0, '', 0) : $obj->code_journal);
-        print '<td class="center">' . $journaltoshow . '</td>';
+        $journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $obj->code_journal);
+        print '<td class="center">'.$journaltoshow.'</td>';
 
-		if (empty($obj->lettering_code)  && empty($obj->date_validated) ) {
-			print '<td class="nowrap center"><input type="checkbox" class="flat checkforselect" name="toselect[]" id="toselect[]" value="' . $obj->rowid . '" /></td>';
-		    print '<td><a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num=' . $obj->piece_num . '">';
+		if (empty($obj->lettering_code) && empty($obj->date_validated)) {
+			print '<td class="nowrap center"><input type="checkbox" class="flat checkforselect" name="toselect[]" id="toselect[]" value="'.$obj->rowid.'" /></td>';
+		    print '<td><a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num='.$obj->piece_num.'">';
 		    print img_edit();
-            print '</a></td>' . "\n";
+            print '</a></td>'."\n";
 		} else {
-            print '<td class="center">' . $obj->lettering_code . '</td>';
+            print '<td class="center">'.$obj->lettering_code.'</td>';
             print '<td></td>';
         }
 
@@ -281,16 +281,16 @@ if ($resql) {
 	}
 
 	print '<tr class="oddeven">';
-	print '<td class="right" colspan="3">'.$langs->trans("Total").':</td>' . "\n";
-	print '<td class="nowrap right"><strong>' . price($debit) . '</strong></td>';
-	print '<td class="nowrap right"><strong>' . price($credit) . '</strong></td>';
+	print '<td class="right" colspan="3">'.$langs->trans("Total").':</td>'."\n";
+	print '<td class="nowrap right"><strong>'.price($debit).'</strong></td>';
+	print '<td class="nowrap right"><strong>'.price($credit).'</strong></td>';
 	print '<td colspan="6"></td>';
 	print "</tr>\n";
 
 	print '<tr class="oddeven">';
-	print '<td class="right" colspan="3">'.$langs->trans("Balancing").':</td>' . "\n";
+	print '<td class="right" colspan="3">'.$langs->trans("Balancing").':</td>'."\n";
 	print '<td colspan="2">&nbsp;</td>';
-	print '<td class="nowrap right"><strong>' . price($credit - $debit) . '</strong></td>';
+	print '<td class="nowrap right"><strong>'.price($credit - $debit).'</strong></td>';
 	print '<td colspan="4"></td>';
 	print "</tr>\n";
 

+ 177 - 177
htdocs/accountancy/class/accountancycategory.class.php

@@ -24,7 +24,7 @@
  */
 
 // Class
-require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
 
 /**
  * Class to manage categories of an accounting account
@@ -49,12 +49,12 @@ class AccountancyCategory // extends CommonObject
 	/**
 	 * @var string ID to identify managed object
 	 */
-	public $element='c_accounting_category';
+	public $element = 'c_accounting_category';
 
 	/**
 	 * @var string Name of table without prefix where object is stored
 	 */
-	public $table_element='c_accounting_category';
+	public $table_element = 'c_accounting_category';
 
 	/**
 	 * @var int ID
@@ -150,15 +150,15 @@ class AccountancyCategory // extends CommonObject
 	public function create($user, $notrigger = 0)
 	{
 		global $conf, $langs;
-		$error=0;
+		$error = 0;
 
 		// Clean parameters
-		if (isset($this->code)) $this->code=trim($this->code);
-		if (isset($this->label)) $this->label=trim($this->label);
-		if (isset($this->range_account)) $this->range_account=trim($this->range_account);
+		if (isset($this->code)) $this->code = trim($this->code);
+		if (isset($this->label)) $this->label = trim($this->label);
+		if (isset($this->range_account)) $this->range_account = trim($this->range_account);
 		if (isset($this->sens)) $this->sens = (int) $this->sens;
 		if (isset($this->category_type)) $this->category_type = (int) $this->category_type;
-		if (isset($this->formula)) $this->formula=trim($this->formula);
+		if (isset($this->formula)) $this->formula = trim($this->formula);
 		if (isset($this->position)) $this->position = (int) $this->position;
 		if (isset($this->fk_country)) $this->fk_country = (int) $this->fk_country;
 		if (isset($this->active)) $this->active = (int) $this->active;
@@ -168,47 +168,47 @@ class AccountancyCategory // extends CommonObject
 
 		// Insert request
 		$sql = "INSERT INTO ".MAIN_DB_PREFIX."c_accounting_category(";
-		if ($this->rowid > 0) $sql.= "rowid, ";
-		$sql.= "code, ";
-		$sql.= "label, ";
-		$sql.= "range_account, ";
-		$sql.= "sens, ";
-		$sql.= "category_type, ";
-		$sql.= "formula, ";
-		$sql.= "position, ";
-		$sql.= "fk_country, ";
-		$sql.= "active, ";
-		$sql.= "entity";
-		$sql.= ") VALUES (";
-		if ($this->rowid > 0) $sql.= " ".$this->rowid.",";
-		$sql.= " ".(! isset($this->code)?'NULL':"'".$this->db->escape($this->code)."'").",";
-		$sql.= " ".(! isset($this->label)?'NULL':"'".$this->db->escape($this->label)."'").",";
-		$sql.= " ".(! isset($this->range_account)?'NULL':"'".$this->db->escape($this->range_account)."'").",";
-		$sql.= " ".(! isset($this->sens)?'NULL':"'".$this->db->escape($this->sens)."'").",";
-		$sql.= " ".(! isset($this->category_type)?'NULL':"'".$this->db->escape($this->category_type)."'").",";
-		$sql.= " ".(! isset($this->formula)?'NULL':"'".$this->db->escape($this->formula)."'").",";
-		$sql.= " ".(! isset($this->position)?'NULL':$this->db->escape($this->position)).",";
-		$sql.= " ".(! isset($this->fk_country)?'NULL':$this->db->escape($this->fk_country)).",";
-		$sql.= " ".(! isset($this->active)?'NULL':$this->db->escape($this->active));
-		$sql.= ", ".$conf->entity;
-		$sql.= ")";
+		if ($this->rowid > 0) $sql .= "rowid, ";
+		$sql .= "code, ";
+		$sql .= "label, ";
+		$sql .= "range_account, ";
+		$sql .= "sens, ";
+		$sql .= "category_type, ";
+		$sql .= "formula, ";
+		$sql .= "position, ";
+		$sql .= "fk_country, ";
+		$sql .= "active, ";
+		$sql .= "entity";
+		$sql .= ") VALUES (";
+		if ($this->rowid > 0) $sql .= " ".$this->rowid.",";
+		$sql .= " ".(!isset($this->code) ? 'NULL' : "'".$this->db->escape($this->code)."'").",";
+		$sql .= " ".(!isset($this->label) ? 'NULL' : "'".$this->db->escape($this->label)."'").",";
+		$sql .= " ".(!isset($this->range_account) ? 'NULL' : "'".$this->db->escape($this->range_account)."'").",";
+		$sql .= " ".(!isset($this->sens) ? 'NULL' : "'".$this->db->escape($this->sens)."'").",";
+		$sql .= " ".(!isset($this->category_type) ? 'NULL' : "'".$this->db->escape($this->category_type)."'").",";
+		$sql .= " ".(!isset($this->formula) ? 'NULL' : "'".$this->db->escape($this->formula)."'").",";
+		$sql .= " ".(!isset($this->position) ? 'NULL' : $this->db->escape($this->position)).",";
+		$sql .= " ".(!isset($this->fk_country) ? 'NULL' : $this->db->escape($this->fk_country)).",";
+		$sql .= " ".(!isset($this->active) ? 'NULL' : $this->db->escape($this->active));
+		$sql .= ", ".$conf->entity;
+		$sql .= ")";
 
 		$this->db->begin();
 
 		dol_syslog(get_class($this)."::create", LOG_DEBUG);
-		$resql=$this->db->query($sql);
-		if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
+		$resql = $this->db->query($sql);
+		if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
 
 		// Commit or rollback
 		if ($error)
 		{
-			foreach($this->errors as $errmsg)
+			foreach ($this->errors as $errmsg)
 			{
 				dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
-				$this->error.=($this->error?', '.$errmsg:$errmsg);
+				$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
 			}
 			$this->db->rollback();
-			return -1*$error;
+			return -1 * $error;
 		}
 		else
 		{
@@ -229,27 +229,27 @@ class AccountancyCategory // extends CommonObject
 	public function fetch($id, $code = '', $label = '')
 	{
 		$sql = "SELECT";
-		$sql.= " t.rowid,";
-		$sql.= " t.code,";
-		$sql.= " t.label,";
-		$sql.= " t.range_account,";
-		$sql.= " t.sens,";
-		$sql.= " t.category_type,";
-		$sql.= " t.formula,";
-		$sql.= " t.position,";
-		$sql.= " t.fk_country,";
-		$sql.= " t.active";
-		$sql.= " FROM ".MAIN_DB_PREFIX."c_accounting_category as t";
-		if ($id)   $sql.= " WHERE t.rowid = ".$id;
+		$sql .= " t.rowid,";
+		$sql .= " t.code,";
+		$sql .= " t.label,";
+		$sql .= " t.range_account,";
+		$sql .= " t.sens,";
+		$sql .= " t.category_type,";
+		$sql .= " t.formula,";
+		$sql .= " t.position,";
+		$sql .= " t.fk_country,";
+		$sql .= " t.active";
+		$sql .= " FROM ".MAIN_DB_PREFIX."c_accounting_category as t";
+		if ($id)   $sql .= " WHERE t.rowid = ".$id;
 		else
 		{
-			$sql.= " WHERE t.entity IN (".getEntity('c_accounting_category').")"; // Dont't use entity if you use rowid
-			if ($code) $sql.= " AND t.code = '".$this->db->escape($code)."'";
-			elseif ($label) $sql.= " AND t.label = '".$this->db->escape($label)."'";
+			$sql .= " WHERE t.entity IN (".getEntity('c_accounting_category').")"; // Dont't use entity if you use rowid
+			if ($code) $sql .= " AND t.code = '".$this->db->escape($code)."'";
+			elseif ($label) $sql .= " AND t.label = '".$this->db->escape($label)."'";
 		}
 
 		dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
-		$resql=$this->db->query($sql);
+		$resql = $this->db->query($sql);
 		if ($resql)
 		{
 			if ($this->db->num_rows($resql))
@@ -273,7 +273,7 @@ class AccountancyCategory // extends CommonObject
 		}
 		else
 		{
-			$this->error="Error ".$this->db->lasterror();
+			$this->error = "Error ".$this->db->lasterror();
 			return -1;
 		}
 	}
@@ -289,15 +289,15 @@ class AccountancyCategory // extends CommonObject
 	public function update($user = null, $notrigger = 0)
 	{
 		global $conf, $langs;
-		$error=0;
+		$error = 0;
 
 		// Clean parameters
-		if (isset($this->code)) $this->code=trim($this->code);
-		if (isset($this->label)) $this->label=trim($this->label);
-		if (isset($this->range_account)) $this->range_account=trim($this->range_account);
+		if (isset($this->code)) $this->code = trim($this->code);
+		if (isset($this->label)) $this->label = trim($this->label);
+		if (isset($this->range_account)) $this->range_account = trim($this->range_account);
 		if (isset($this->sens)) $this->sens = (int) $this->sens;
 		if (isset($this->category_type)) $this->category_type = (int) $this->category_type;
-		if (isset($this->formula)) $this->formula=trim($this->formula);
+		if (isset($this->formula)) $this->formula = trim($this->formula);
 		if (isset($this->position)) $this->position = (int) $this->position;
 		if (isset($this->fk_country)) $this->fk_country = (int) $this->fk_country;
 		if (isset($this->active)) $this->active = (int) $this->active;
@@ -308,33 +308,33 @@ class AccountancyCategory // extends CommonObject
 
 		// Update request
 		$sql = "UPDATE ".MAIN_DB_PREFIX."c_accounting_category SET";
-		$sql.= " code=".(isset($this->code)?"'".$this->db->escape($this->code)."'":"null").",";
-		$sql.= " label=".(isset($this->label)?"'".$this->db->escape($this->label)."'":"null").",";
-		$sql.= " range_account=".(isset($this->range_account)?"'".$this->db->escape($this->range_account)."'":"null").",";
-		$sql.= " sens=".(isset($this->sens)?$this->sens:"null").",";
-		$sql.= " category_type=".(isset($this->category_type)?$this->category_type:"null").",";
-		$sql.= " formula=".(isset($this->formula)?"'".$this->db->escape($this->formula)."'":"null").",";
-		$sql.= " position=".(isset($this->position)?$this->position:"null").",";
-		$sql.= " fk_country=".(isset($this->fk_country)?$this->fk_country:"null").",";
-		$sql.= " active=".(isset($this->active)?$this->active:"null")."";
-		$sql.= " WHERE rowid=".$this->id;
+		$sql .= " code=".(isset($this->code) ? "'".$this->db->escape($this->code)."'" : "null").",";
+		$sql .= " label=".(isset($this->label) ? "'".$this->db->escape($this->label)."'" : "null").",";
+		$sql .= " range_account=".(isset($this->range_account) ? "'".$this->db->escape($this->range_account)."'" : "null").",";
+		$sql .= " sens=".(isset($this->sens) ? $this->sens : "null").",";
+		$sql .= " category_type=".(isset($this->category_type) ? $this->category_type : "null").",";
+		$sql .= " formula=".(isset($this->formula) ? "'".$this->db->escape($this->formula)."'" : "null").",";
+		$sql .= " position=".(isset($this->position) ? $this->position : "null").",";
+		$sql .= " fk_country=".(isset($this->fk_country) ? $this->fk_country : "null").",";
+		$sql .= " active=".(isset($this->active) ? $this->active : "null")."";
+		$sql .= " WHERE rowid=".$this->id;
 
 		$this->db->begin();
 
 		dol_syslog(get_class($this)."::update", LOG_DEBUG);
 		$resql = $this->db->query($sql);
-		if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
+		if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
 
 		// Commit or rollback
 		if ($error)
 		{
-			foreach($this->errors as $errmsg)
+			foreach ($this->errors as $errmsg)
 			{
 				dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
-				$this->error.=($this->error?', '.$errmsg:$errmsg);
+				$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
 			}
 			$this->db->rollback();
-			return -1*$error;
+			return -1 * $error;
 		}
 		else
 		{
@@ -354,27 +354,27 @@ class AccountancyCategory // extends CommonObject
 	public function delete($user, $notrigger = 0)
 	{
 		global $conf, $langs;
-		$error=0;
+		$error = 0;
 
 		$sql = "DELETE FROM ".MAIN_DB_PREFIX."c_accounting_category";
-		$sql.= " WHERE rowid=".$this->id;
+		$sql .= " WHERE rowid=".$this->id;
 
 		$this->db->begin();
 
 		dol_syslog(get_class($this)."::delete", LOG_DEBUG);
 		$resql = $this->db->query($sql);
-		if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
+		if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
 
 		// Commit or rollback
 		if ($error)
 		{
-			foreach($this->errors as $errmsg)
+			foreach ($this->errors as $errmsg)
 			{
 				dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
-				$this->error.=($this->error?', '.$errmsg:$errmsg);
+				$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
 			}
 			$this->db->rollback();
-			return -1*$error;
+			return -1 * $error;
 		}
 		else
 		{
@@ -394,28 +394,28 @@ class AccountancyCategory // extends CommonObject
     {
 		global $conf;
 		$sql = "SELECT t.rowid, t.account_number, t.label";
-		$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as t";
-		$sql .= " WHERE t.fk_accounting_category = " . $id;
-		$sql .= " AND t.entity = " . $conf->entity;
+		$sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t";
+		$sql .= " WHERE t.fk_accounting_category = ".$id;
+		$sql .= " AND t.entity = ".$conf->entity;
 
 		$this->lines_display = array();
 
-		dol_syslog(__METHOD__ . " sql=" . $sql, LOG_DEBUG);
+		dol_syslog(__METHOD__." sql=".$sql, LOG_DEBUG);
 		$resql = $this->db->query($sql);
 		if ($resql) {
 			$num = $this->db->num_rows($resql);
 			if ($num) {
-				while ( $obj = $this->db->fetch_object($resql) ) {
+				while ($obj = $this->db->fetch_object($resql)) {
 					$this->lines_display[] = $obj;
 				}
 			}
 			return $num;
 		} else {
-			$this->error = "Error " . $this->db->lasterror();
+			$this->error = "Error ".$this->db->lasterror();
 			$this->errors[] = $this->error;
-			dol_syslog(__METHOD__ . " " . implode(',' . $this->errors), LOG_ERR);
+			dol_syslog(__METHOD__." ".implode(','.$this->errors), LOG_ERR);
 
-			return - 1;
+			return -1;
 		}
     }
 
@@ -431,40 +431,40 @@ class AccountancyCategory // extends CommonObject
 		global $conf;
 
 		$sql = "SELECT t.numero_compte, t.label_operation, t.doc_ref";
-		$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as t";
+		$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as t";
 		$sql .= " WHERE t.numero_compte NOT IN (";
 		$sql .= " SELECT t.account_number";
-		$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as t";
-		$sql .= " WHERE t.fk_accounting_category = " . $id . " AND t.entity = " . $conf->entity.")";
+		$sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t";
+		$sql .= " WHERE t.fk_accounting_category = ".$id." AND t.entity = ".$conf->entity.")";
 		$sql .= " AND t.numero_compte IN (";
 		$sql .= " SELECT DISTINCT aa.account_number";
-		$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa";
-		$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
-		$sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS;
+		$sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa";
+		$sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
+		$sql .= " AND asy.rowid = ".$conf->global->CHARTOFACCOUNTS;
 		$sql .= " AND aa.active = 1";
-		$sql .= " AND aa.entity = " . $conf->entity . ")";
+		$sql .= " AND aa.entity = ".$conf->entity.")";
 		$sql .= " GROUP BY t.numero_compte, t.label_operation, t.doc_ref";
 		$sql .= " ORDER BY t.numero_compte";
 
-		$this->lines_CptBk = array ();
+		$this->lines_CptBk = array();
 
 		dol_syslog(__METHOD__, LOG_DEBUG);
 		$resql = $this->db->query($sql);
 		if ($resql) {
 			$num = $this->db->num_rows($resql);
 			if ($num) {
-				while ( $obj = $this->db->fetch_object($resql) ) {
+				while ($obj = $this->db->fetch_object($resql)) {
 					$this->lines_cptbk[] = $obj;
 				}
 			}
 
 			return $num;
 		} else {
-			$this->error = "Error " . $this->db->lasterror();
+			$this->error = "Error ".$this->db->lasterror();
 			$this->errors[] = $this->error;
-			dol_syslog(__METHOD__ . " " . implode(',' . $this->errors), LOG_ERR);
+			dol_syslog(__METHOD__." ".implode(','.$this->errors), LOG_ERR);
 
-			return - 1;
+			return -1;
 		}
     }
 
@@ -480,34 +480,34 @@ class AccountancyCategory // extends CommonObject
         global $conf;
 
 	    $sql = "SELECT aa.account_number as numero_compte, aa.label as label_compte";
-	    $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa";
-	    $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
+	    $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa";
+	    $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
 	    $sql .= " WHERE (aa.fk_accounting_category != ".$id." OR aa.fk_accounting_category IS NULL)";
-	    $sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS;
+	    $sql .= " AND asy.rowid = ".$conf->global->CHARTOFACCOUNTS;
 	    $sql .= " AND aa.active = 1";
-	    $sql .= " AND aa.entity = " . $conf->entity;
+	    $sql .= " AND aa.entity = ".$conf->entity;
 	    $sql .= " GROUP BY aa.account_number, aa.label";
 	    $sql .= " ORDER BY aa.account_number, aa.label";
 
-	    $this->lines_CptBk = array ();
+	    $this->lines_CptBk = array();
 
 	    dol_syslog(__METHOD__, LOG_DEBUG);
 	    $resql = $this->db->query($sql);
 	    if ($resql) {
 	        $num = $this->db->num_rows($resql);
 	        if ($num) {
-	            while ( $obj = $this->db->fetch_object($resql) ) {
+	            while ($obj = $this->db->fetch_object($resql)) {
 	                $this->lines_cptbk[] = $obj;
 	            }
 	        }
 
 	        return $num;
 	    } else {
-	        $this->error = "Error " . $this->db->lasterror();
+	        $this->error = "Error ".$this->db->lasterror();
 	        $this->errors[] = $this->error;
-	        dol_syslog(__METHOD__ . " " . implode(',' . $this->errors), LOG_ERR);
+	        dol_syslog(__METHOD__." ".implode(','.$this->errors), LOG_ERR);
 
-	        return - 1;
+	        return -1;
 	    }
     }
 
@@ -527,42 +527,42 @@ class AccountancyCategory // extends CommonObject
 		require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
 
 		$sql = "SELECT aa.rowid, aa.account_number";
-		$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa";
-		$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
-		$sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS;
+		$sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa";
+		$sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
+		$sql .= " AND asy.rowid = ".$conf->global->CHARTOFACCOUNTS;
 		$sql .= " AND aa.active = 1";
-		$sql .= " AND aa.entity = " . $conf->entity;
-        $sql .= " ORDER BY LENGTH(aa.account_number) DESC;";    // LENGTH is ok with mysql and postgresql
+		$sql .= " AND aa.entity = ".$conf->entity;
+        $sql .= " ORDER BY LENGTH(aa.account_number) DESC;"; // LENGTH is ok with mysql and postgresql
 
 		$this->db->begin();
 
 		dol_syslog(__METHOD__, LOG_DEBUG);
 		$resql = $this->db->query($sql);
-		if (! $resql) {
-			$error ++;
-			$this->errors[] = "Error " . $this->db->lasterror();
+		if (!$resql) {
+			$error++;
+			$this->errors[] = "Error ".$this->db->lasterror();
 			$this->db->rollback();
 			return -1;
 		}
 
-		$accountincptsadded=array();
+		$accountincptsadded = array();
 		while ($obj = $this->db->fetch_object($resql))
 		{
-		    $account_number_formated=length_accountg($obj->account_number);
-		    if (! empty($accountincptsadded[$account_number_formated])) continue;
+		    $account_number_formated = length_accountg($obj->account_number);
+		    if (!empty($accountincptsadded[$account_number_formated])) continue;
 
 		    if (array_key_exists($account_number_formated, $cpts))
 			{
-			    $accountincptsadded[$account_number_formated]=1;
+			    $accountincptsadded[$account_number_formated] = 1;
 			    // We found an account number that is in list $cpts of account to add
-				$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account";
-				$sql .= " SET fk_accounting_category=" . $id_cat;
+				$sql = "UPDATE ".MAIN_DB_PREFIX."accounting_account";
+				$sql .= " SET fk_accounting_category=".$id_cat;
 				$sql .= " WHERE rowid=".$obj->rowid;
 				dol_syslog(__METHOD__, LOG_DEBUG);
 				$resqlupdate = $this->db->query($sql);
-				if (! $resqlupdate) {
-					$error ++;
-					$this->errors[] = "Error " . $this->db->lasterror();
+				if (!$resqlupdate) {
+					$error++;
+					$this->errors[] = "Error ".$this->db->lasterror();
 				}
 			}
 		}
@@ -570,12 +570,12 @@ class AccountancyCategory // extends CommonObject
 		// Commit or rollback
 		if ($error) {
 			foreach ($this->errors as $errmsg) {
-				dol_syslog(__METHOD__ . " " . $errmsg, LOG_ERR);
-				$this->error .= ($this->error ? ', ' . $errmsg : $errmsg);
+				dol_syslog(__METHOD__." ".$errmsg, LOG_ERR);
+				$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
 			}
 			$this->db->rollback();
 
-			return - 1 * $error;
+			return -1 * $error;
 		} else {
 			$this->db->commit();
 
@@ -594,27 +594,27 @@ class AccountancyCategory // extends CommonObject
     {
 		$error = 0;
 
-		$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account as aa";
+		$sql = "UPDATE ".MAIN_DB_PREFIX."accounting_account as aa";
 		$sql .= " SET fk_accounting_category= 0";
-		$sql .= " WHERE aa.rowid= " . $cpt_id;
+		$sql .= " WHERE aa.rowid= ".$cpt_id;
 		$this->db->begin();
 
-		dol_syslog(__METHOD__ . " sql=" . $sql, LOG_DEBUG);
+		dol_syslog(__METHOD__." sql=".$sql, LOG_DEBUG);
 		$resql = $this->db->query($sql);
-		if (! $resql) {
-			$error ++;
-			$this->errors[] = "Error " . $this->db->lasterror();
+		if (!$resql) {
+			$error++;
+			$this->errors[] = "Error ".$this->db->lasterror();
 		}
 
 		// Commit or rollback
         if ($error) {
 			foreach ($this->errors as $errmsg) {
-				dol_syslog(__METHOD__ . " " . $errmsg, LOG_ERR);
-				$this->error .= ($this->error ? ', ' . $errmsg : $errmsg);
+				dol_syslog(__METHOD__." ".$errmsg, LOG_ERR);
+				$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
 			}
 			$this->db->rollback();
 
-			return - 1 * $error;
+			return -1 * $error;
         } else {
 			$this->db->commit();
 
@@ -637,14 +637,14 @@ class AccountancyCategory // extends CommonObject
 		}
 
 		$sql = "SELECT t.rowid, t.account_number, t.label as account_label, cat.code, cat.position, cat.label as name_cat, cat.sens ";
-		$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as t, " . MAIN_DB_PREFIX . "c_accounting_category as cat";
+		$sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t, ".MAIN_DB_PREFIX."c_accounting_category as cat";
 		$sql .= " WHERE t.fk_accounting_category IN ( SELECT c.rowid ";
-		$sql .= " FROM " . MAIN_DB_PREFIX . "c_accounting_category as c";
+		$sql .= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c";
 		$sql .= " WHERE c.active = 1";
-		$sql .= " AND c.entity = " . $conf->entity;
+		$sql .= " AND c.entity = ".$conf->entity;
 		$sql .= " AND (c.fk_country = ".$mysoc->country_id." OR c.fk_country = 0)";
 		$sql .= " AND cat.rowid = t.fk_accounting_category";
-		$sql .= " AND t.entity = " . $conf->entity;
+		$sql .= " AND t.entity = ".$conf->entity;
 		$sql .= " ORDER BY cat.position ASC";
 
 		$resql = $this->db->query($sql);
@@ -652,11 +652,11 @@ class AccountancyCategory // extends CommonObject
 			$i = 0;
 			$obj = '';
 			$num = $this->db->num_rows($resql);
-			$data = array ();
+			$data = array();
 			if ($num) {
-				while ( $obj = $this->db->fetch_object($resql) ) {
+				while ($obj = $this->db->fetch_object($resql)) {
 					$name_cat = $obj->name_cat;
-					$data[$name_cat][$i] = array (
+					$data[$name_cat][$i] = array(
 							'id' => $obj->rowid,
 							'code' => $obj->code,
 							'position' => $obj->position,
@@ -664,13 +664,13 @@ class AccountancyCategory // extends CommonObject
 							'account_label' => $obj->account_label,
 							'sens' => $obj->sens
 					);
-					$i ++;
+					$i++;
 				}
 			}
 			return $data;
 		} else {
-			$this->error = "Error " . $this->db->lasterror();
-			dol_syslog(__METHOD__ . " " . $this->error, LOG_ERR);
+			$this->error = "Error ".$this->db->lasterror();
+			dol_syslog(__METHOD__." ".$this->error, LOG_ERR);
 
 			return -1;
 		}
@@ -696,34 +696,34 @@ class AccountancyCategory // extends CommonObject
 		$this->sdcpermonth = array();
 
 		$sql = "SELECT SUM(t.debit) as debit, SUM(t.credit) as credit";
-		if (is_array($cpt)) $sql.=", t.numero_compte as accountancy_account";
-		$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as t";
+		if (is_array($cpt)) $sql .= ", t.numero_compte as accountancy_account";
+		$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as t";
 		//if (in_array($this->db->type, array('mysql', 'mysqli'))) $sql.=' USE INDEX idx_accounting_bookkeeping_doc_date';
 		$sql .= " WHERE t.entity = ".$conf->entity;
 		if (is_array($cpt))
 		{
-			$listofaccount='';
-			foreach($cpt as $cptcursor)
+			$listofaccount = '';
+			foreach ($cpt as $cptcursor)
 			{
-				if ($listofaccount) $listofaccount.=",";
-				$listofaccount.="'".$cptcursor."'";
+				if ($listofaccount) $listofaccount .= ",";
+				$listofaccount .= "'".$cptcursor."'";
 			}
-			$sql .= " AND t.numero_compte IN (" .$listofaccount. ")";
+			$sql .= " AND t.numero_compte IN (".$listofaccount.")";
 		}
 		else
 		{
-			$sql .= " AND t.numero_compte = '" . $this->db->escape($cpt) . "'";
+			$sql .= " AND t.numero_compte = '".$this->db->escape($cpt)."'";
 		}
-		if (! empty($date_start) && ! empty($date_end) && (empty($month) || empty($year)))	// If month/year provided, it is stronger than filter date_start/date_end
+		if (!empty($date_start) && !empty($date_end) && (empty($month) || empty($year)))	// If month/year provided, it is stronger than filter date_start/date_end
 			$sql .= " AND (t.doc_date BETWEEN '".$this->db->idate($date_start)."' AND '".$this->db->idate($date_end)."')";
-		if (! empty($month) && ! empty($year)) {
+		if (!empty($month) && !empty($year)) {
 			$sql .= " AND (t.doc_date BETWEEN '".$this->db->idate(dol_get_first_day($year, $month))."' AND '".$this->db->idate(dol_get_last_day($year, $month))."')";
 		}
 		if ($thirdparty_code != 'nofilter')
 		{
 			$sql .= " AND t.thirdparty_code = '".$this->db->escape($thirdparty_code)."'";
 		}
-		if (is_array($cpt)) $sql.=" GROUP BY t.numero_compte";
+		if (is_array($cpt)) $sql .= " GROUP BY t.numero_compte";
 		//print $sql;
 
 		$resql = $this->db->query($sql);
@@ -745,9 +745,9 @@ class AccountancyCategory // extends CommonObject
 			}
 			return $num;
 		} else {
-			$this->error = "Error " . $this->db->lasterror();
+			$this->error = "Error ".$this->db->lasterror();
 			$this->errors[] = $this->error;
-			dol_syslog(__METHOD__ . " " . $this->error, LOG_ERR);
+			dol_syslog(__METHOD__." ".$this->error, LOG_ERR);
 			return -1;
 		}
 	}
@@ -768,10 +768,10 @@ class AccountancyCategory // extends CommonObject
 		}
 
 		$sql = "SELECT c.rowid, c.code, c.label, c.formula, c.position, c.category_type, c.sens";
-		$sql .= " FROM " . MAIN_DB_PREFIX . "c_accounting_category as c";
+		$sql .= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c";
 		$sql .= " WHERE c.active = 1";
-		$sql .= " AND c.entity = " . $conf->entity;
-		if ($categorytype >= 0) $sql.=" AND c.category_type = 1";
+		$sql .= " AND c.entity = ".$conf->entity;
+		if ($categorytype >= 0) $sql .= " AND c.category_type = 1";
 		$sql .= " AND (c.fk_country = ".$mysoc->country_id." OR c.fk_country = 0)";
 		$sql .= " ORDER BY c.position ASC";
 
@@ -780,12 +780,12 @@ class AccountancyCategory // extends CommonObject
 			$i = 0;
 			$obj = '';
 			$num = $this->db->num_rows($resql);
-			$data = array ();
+			$data = array();
 			if ($num) {
-				while ( $i < $num ) {
+				while ($i < $num) {
 					$obj = $this->db->fetch_object($resql);
 
-					$data[] = array (
+					$data[] = array(
 							'rowid' => $obj->rowid,
 							'code' => $obj->code,
 							'label' => $obj->label,
@@ -799,11 +799,11 @@ class AccountancyCategory // extends CommonObject
 			}
 			return $data;
 		} else {
-			$this->error = "Error " . $this->db->lasterror();
+			$this->error = "Error ".$this->db->lasterror();
 			$this->errors[] = $this->error;
-			dol_syslog(__METHOD__ . " " . implode(',', $this->errors), LOG_ERR);
+			dol_syslog(__METHOD__." ".implode(',', $this->errors), LOG_ERR);
 
-			return - 1;
+			return -1;
 		}
 	}
 
@@ -826,20 +826,20 @@ class AccountancyCategory // extends CommonObject
 			exit();
 		}
 
-		if (! empty($cat_id))
+		if (!empty($cat_id))
 		{
 			$sql = "SELECT t.rowid, t.account_number, t.label as account_label";
-			$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as t";
+			$sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t";
 			$sql .= " WHERE t.fk_accounting_category = ".$cat_id;
-			$sql .= " AND t.entity = " . $conf->entity;
+			$sql .= " AND t.entity = ".$conf->entity;
 			$sql .= " ORDER BY t.account_number";
 		}
 		else
 		{
 			$sql = "SELECT t.rowid, t.account_number, t.label as account_label";
-			$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as t";
+			$sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t";
 			$sql .= " WHERE ".$predefinedgroupwhere;
-			$sql .= " AND t.entity = " . $conf->entity;
+			$sql .= " AND t.entity = ".$conf->entity;
 			$sql .= " ORDER BY t.account_number";
 		}
 		//echo $sql;
@@ -853,7 +853,7 @@ class AccountancyCategory // extends CommonObject
 			if ($num) {
 				while ($obj = $this->db->fetch_object($resql))
 				{
-					$data[] = array (
+					$data[] = array(
 							'id' => $obj->rowid,
 							'account_number' => $obj->account_number,
 							'account_label' => $obj->account_label,
@@ -863,8 +863,8 @@ class AccountancyCategory // extends CommonObject
 			}
 			return $data;
 		} else {
-			$this->error = "Error " . $this->db->lasterror();
-			dol_syslog(__METHOD__ . " " . $this->error, LOG_ERR);
+			$this->error = "Error ".$this->db->lasterror();
+			dol_syslog(__METHOD__." ".$this->error, LOG_ERR);
 
 			return -1;
 		}

+ 13 - 13
htdocs/accountancy/class/accountancyexport.class.php

@@ -1079,28 +1079,28 @@ class AccountancyExport
 
 		foreach ($objectLines as $line) {
 			// TYPE C
-			if($last_codeinvoice != $line->doc_ref){
+			if ($last_codeinvoice != $line->doc_ref) {
 				//recherche societe en fonction de son code client
-				$sql = "SELECT code_client, fk_forme_juridique, nom, address, zip, town, fk_pays, phone, siret FROM ".MAIN_DB_PREFIX."societe WHERE code_client = '".$line->thirdparty_code ."'";
+				$sql = "SELECT code_client, fk_forme_juridique, nom, address, zip, town, fk_pays, phone, siret FROM ".MAIN_DB_PREFIX."societe WHERE code_client = '".$line->thirdparty_code."'";
 				$resql = $this->db->query($sql);
 
-				if($resql && $this->db->num_rows($resql)>0)
+				if ($resql && $this->db->num_rows($resql) > 0)
 				{
 					$soc = $this->db->fetch_object($resql);
 
-	                $address=array('','','');
-                    if (strpos($soc->address, "\n")!==false) {
+	                $address = array('', '', '');
+                    if (strpos($soc->address, "\n") !== false) {
 	                    $address = explode("\n", $soc->address);
-	                    if (is_array($address) && count($address)>0) {
-	                    	foreach($address as $key=>$data) {
-			                    $address[$key]=str_replace(array("\t", "\n", "\r"), "", $data);
-			                    $address[$key]=dol_trunc($address[$key], 40, 'right', 'UTF-8', 1);
+	                    if (is_array($address) && count($address) > 0) {
+	                    	foreach ($address as $key=>$data) {
+			                    $address[$key] = str_replace(array("\t", "\n", "\r"), "", $data);
+			                    $address[$key] = dol_trunc($address[$key], 40, 'right', 'UTF-8', 1);
 		                    }
 	                    }
                     } else {
-	                    $address[0] =  substr(str_replace(array("\t", "\r"), " ", $soc->address), 0, 40);
-	                    $address[1] =  substr(str_replace(array("\t", "\r"), " ", $soc->address), 41, 40);
-	                    $address[2] =  substr(str_replace(array("\t", "\r"), " ", $soc->address), 82, 40);
+	                    $address[0] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 0, 40);
+	                    $address[1] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 41, 40);
+	                    $address[2] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 82, 40);
                     }
 
 					$type_enregistrement = 'C';
@@ -1254,7 +1254,7 @@ class AccountancyExport
 			$racine_subledger_account = ''; // for records of type E leave this field blank
 			//			}
 
-			print $racine_subledger_account . $separator; // deprecated CPTG & CPTA use instead
+			print $racine_subledger_account.$separator; // deprecated CPTG & CPTA use instead
 			// MONT
 			print price(abs($line->montant), 0, '', 1, 2).$separator;
 			// CODC

+ 11 - 11
htdocs/accountancy/class/accountancysystem.class.php

@@ -98,15 +98,15 @@ class AccountancySystem
 	    if ($rowid > 0 || $ref)
 	    {
 	        $sql  = "SELECT a.rowid, a.pcg_version, a.label, a.active";
-	        $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_system as a";
+	        $sql .= " FROM ".MAIN_DB_PREFIX."accounting_system as a";
 	        $sql .= " WHERE";
 	        if ($rowid) {
-	            $sql .= " a.rowid = '" . $rowid . "'";
+	            $sql .= " a.rowid = '".$rowid."'";
 	        } elseif ($ref) {
-	            $sql .= " a.pcg_version = '" . $this->db->escape($ref) . "'";
+	            $sql .= " a.pcg_version = '".$this->db->escape($ref)."'";
 	        }
 
-	        dol_syslog(get_class($this) . "::fetch sql=" . $sql, LOG_DEBUG);
+	        dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
 	        $result = $this->db->query($sql);
 	        if ($result) {
 	            $obj = $this->db->fetch_object($result);
@@ -124,11 +124,11 @@ class AccountancySystem
 	                return 0;
 	            }
 	        } else {
-	            $this->error = "Error " . $this->db->lasterror();
-	            $this->errors[] = "Error " . $this->db->lasterror();
+	            $this->error = "Error ".$this->db->lasterror();
+	            $this->errors[] = "Error ".$this->db->lasterror();
 	        }
 	    }
-	    return - 1;
+	    return -1;
 	}
 
 
@@ -142,14 +142,14 @@ class AccountancySystem
     {
 		$now = dol_now();
 
-		$sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_system";
+		$sql = "INSERT INTO ".MAIN_DB_PREFIX."accounting_system";
 		$sql .= " (date_creation, fk_user_author, numero, label)";
-		$sql .= " VALUES ('" . $this->db->idate($now) . "'," . $user->id . ",'" . $this->db->escape($this->numero) . "','" . $this->db->escape($this->label) . "')";
+		$sql .= " VALUES ('".$this->db->idate($now)."',".$user->id.",'".$this->db->escape($this->numero)."','".$this->db->escape($this->label)."')";
 
-		dol_syslog(get_class($this) . "::create sql=" . $sql, LOG_DEBUG);
+		dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG);
 		$resql = $this->db->query($sql);
 		if ($resql) {
-			$id = $this->db->last_insert_id(MAIN_DB_PREFIX . "accounting_system");
+			$id = $this->db->last_insert_id(MAIN_DB_PREFIX."accounting_system");
 
 			if ($id > 0) {
 				$this->rowid = $id;

+ 103 - 103
htdocs/accountancy/class/accountingaccount.class.php

@@ -34,12 +34,12 @@ class AccountingAccount extends CommonObject
 	/**
 	 * @var string Name of element
 	 */
-	public $element='accounting_account';
+	public $element = 'accounting_account';
 
 	/**
 	 * @var string Name of table without prefix where object is stored
 	 */
-	public $table_element='accounting_account';
+	public $table_element = 'accounting_account';
 
 	/**
 	 * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
@@ -150,7 +150,7 @@ class AccountingAccount extends CommonObject
 		global $conf;
 
 		$this->db = $db;
-		$this->next_prev_filter='fk_pcg_version IN (SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS . ')';		// Used to add a filter in Form::showrefnav method
+		$this->next_prev_filter = 'fk_pcg_version IN (SELECT pcg_version FROM '.MAIN_DB_PREFIX.'accounting_system WHERE rowid='.$conf->global->CHARTOFACCOUNTS.')'; // Used to add a filter in Form::showrefnav method
     }
 
 	/**
@@ -169,23 +169,23 @@ class AccountingAccount extends CommonObject
 		if ($rowid || $account_number) {
 			$sql  = "SELECT a.rowid as rowid, a.datec, a.tms, a.fk_pcg_version, a.pcg_type, a.account_number, a.account_parent, a.label, a.labelshort, a.fk_accounting_category, a.fk_user_author, a.fk_user_modif, a.active, a.reconcilable";
 			$sql .= ", ca.label as category_label";
-			$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as a";
+			$sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as a";
 			$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_accounting_category as ca ON a.fk_accounting_category = ca.rowid";
 			$sql .= " WHERE";
 			if ($rowid) {
-				$sql .= " a.rowid = " . (int) $rowid;
+				$sql .= " a.rowid = ".(int) $rowid;
 			} elseif ($account_number) {
-				$sql .= " a.account_number = '" . $this->db->escape($account_number) . "'";
+				$sql .= " a.account_number = '".$this->db->escape($account_number)."'";
 				$sql .= " AND a.entity = ".$conf->entity;
 			}
-			if (! empty($limittocurrentchart)) {
-				$sql .= ' AND a.fk_pcg_version IN (SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $this->db->escape($conf->global->CHARTOFACCOUNTS) . ')';
+			if (!empty($limittocurrentchart)) {
+				$sql .= ' AND a.fk_pcg_version IN (SELECT pcg_version FROM '.MAIN_DB_PREFIX.'accounting_system WHERE rowid='.$this->db->escape($conf->global->CHARTOFACCOUNTS).')';
 			}
-			if (! empty($limittoachartaccount)) {
+			if (!empty($limittoachartaccount)) {
 			    $sql .= " AND a.fk_pcg_version = '".$this->db->escape($limittoachartaccount)."'";
 			}
 
-			dol_syslog(get_class($this) . "::fetch sql=" . $sql, LOG_DEBUG);
+			dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
 			$result = $this->db->query($sql);
 			if ($result) {
 				$obj = $this->db->fetch_object($result);
@@ -215,8 +215,8 @@ class AccountingAccount extends CommonObject
 					return 0;
 				}
 			} else {
-				$this->error = "Error " . $this->db->lasterror();
-				$this->errors[] = "Error " . $this->db->lasterror();
+				$this->error = "Error ".$this->db->lasterror();
+				$this->errors[] = "Error ".$this->db->lasterror();
 			}
 		}
 		return -1;
@@ -255,7 +255,7 @@ class AccountingAccount extends CommonObject
 		// Put here code to add control on parameters values
 
 		// Insert request
-		$sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_account(";
+		$sql = "INSERT INTO ".MAIN_DB_PREFIX."accounting_account(";
 		$sql .= "datec";
 		$sql .= ", entity";
 		$sql .= ", fk_pcg_version";
@@ -269,31 +269,31 @@ class AccountingAccount extends CommonObject
 		$sql .= ", active";
 		$sql .= ", reconcilable";
 		$sql .= ") VALUES (";
-		$sql .= " '" . $this->db->idate($now) . "'";
-		$sql .= ", " . $conf->entity;
-		$sql .= ", " . (empty($this->fk_pcg_version) ? 'NULL' : "'" . $this->db->escape($this->fk_pcg_version) . "'");
-		$sql .= ", " . (empty($this->pcg_type) ? 'NULL' : "'" . $this->db->escape($this->pcg_type) . "'");
-		$sql .= ", " . (empty($this->account_number) ? 'NULL' : "'" . $this->db->escape($this->account_number) . "'");
-		$sql .= ", " . (empty($this->account_parent) ? 0 : (int) $this->account_parent);
-		$sql .= ", " . (empty($this->label) ? "''" : "'" . $this->db->escape($this->label) . "'");
-		$sql .= ", " . (empty($this->labelshort) ? "''" : "'" . $this->db->escape($this->labelshort) . "'");
-		$sql .= ", " . (empty($this->account_category) ? 0 : (int) $this->account_category);
-		$sql .= ", " . $user->id;
-		$sql .= ", " . (int) $this->active;
-		$sql .= ", " . (int) $this->reconcilable;
+		$sql .= " '".$this->db->idate($now)."'";
+		$sql .= ", ".$conf->entity;
+		$sql .= ", ".(empty($this->fk_pcg_version) ? 'NULL' : "'".$this->db->escape($this->fk_pcg_version)."'");
+		$sql .= ", ".(empty($this->pcg_type) ? 'NULL' : "'".$this->db->escape($this->pcg_type)."'");
+		$sql .= ", ".(empty($this->account_number) ? 'NULL' : "'".$this->db->escape($this->account_number)."'");
+		$sql .= ", ".(empty($this->account_parent) ? 0 : (int) $this->account_parent);
+		$sql .= ", ".(empty($this->label) ? "''" : "'".$this->db->escape($this->label)."'");
+		$sql .= ", ".(empty($this->labelshort) ? "''" : "'".$this->db->escape($this->labelshort)."'");
+		$sql .= ", ".(empty($this->account_category) ? 0 : (int) $this->account_category);
+		$sql .= ", ".$user->id;
+		$sql .= ", ".(int) $this->active;
+		$sql .= ", ".(int) $this->reconcilable;
 		$sql .= ")";
 
 		$this->db->begin();
 
-		dol_syslog(get_class($this) . "::create sql=" . $sql, LOG_DEBUG);
+		dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG);
 		$resql = $this->db->query($sql);
-		if (! $resql) {
+		if (!$resql) {
 			$error++;
-			$this->errors[] = "Error " . $this->db->lasterror();
+			$this->errors[] = "Error ".$this->db->lasterror();
 		}
 
-		if (! $error) {
-			$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "accounting_account");
+		if (!$error) {
+			$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."accounting_account");
 
 			// Uncomment this and change MYOBJECT to your own tag if you
 			// want this action to call a trigger.
@@ -309,8 +309,8 @@ class AccountingAccount extends CommonObject
 		// Commit or rollback
 		if ($error) {
 			foreach ($this->errors as $errmsg) {
-				dol_syslog(get_class($this) . "::create " . $errmsg, LOG_ERR);
-				$this->error .= ($this->error ? ', ' . $errmsg : $errmsg);
+				dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
+				$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
 			}
 			$this->db->rollback();
 			return -1 * $error;
@@ -336,20 +336,20 @@ class AccountingAccount extends CommonObject
 
 		$this->db->begin();
 
-		$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account ";
-		$sql .= " SET fk_pcg_version = " . ($this->fk_pcg_version ? "'" . $this->db->escape($this->fk_pcg_version) . "'" : "null");
-		$sql .= " , pcg_type = " . ($this->pcg_type ? "'" . $this->db->escape($this->pcg_type) . "'" : "null");
-		$sql .= " , account_number = '" . $this->db->escape($this->account_number) . "'";
-		$sql .= " , account_parent = " . (int) $this->account_parent;
-		$sql .= " , label = " . ($this->label ? "'" . $this->db->escape($this->label) . "'" : "''");
-		$sql .= " , labelshort = " . ($this->labelshort ? "'" . $this->db->escape($this->labelshort) . "'" : "''");
-		$sql .= " , fk_accounting_category = " . (empty($this->account_category) ? 0 : (int) $this->account_category);
-		$sql .= " , fk_user_modif = " . $user->id;
-		$sql .= " , active = " . (int) $this->active;
-		$sql .= " , reconcilable = " . (int) $this->reconcilable;
-		$sql .= " WHERE rowid = " . $this->id;
-
-		dol_syslog(get_class($this) . "::update sql=" . $sql, LOG_DEBUG);
+		$sql = "UPDATE ".MAIN_DB_PREFIX."accounting_account ";
+		$sql .= " SET fk_pcg_version = ".($this->fk_pcg_version ? "'".$this->db->escape($this->fk_pcg_version)."'" : "null");
+		$sql .= " , pcg_type = ".($this->pcg_type ? "'".$this->db->escape($this->pcg_type)."'" : "null");
+		$sql .= " , account_number = '".$this->db->escape($this->account_number)."'";
+		$sql .= " , account_parent = ".(int) $this->account_parent;
+		$sql .= " , label = ".($this->label ? "'".$this->db->escape($this->label)."'" : "''");
+		$sql .= " , labelshort = ".($this->labelshort ? "'".$this->db->escape($this->labelshort)."'" : "''");
+		$sql .= " , fk_accounting_category = ".(empty($this->account_category) ? 0 : (int) $this->account_category);
+		$sql .= " , fk_user_modif = ".$user->id;
+		$sql .= " , active = ".(int) $this->active;
+		$sql .= " , reconcilable = ".(int) $this->reconcilable;
+		$sql .= " WHERE rowid = ".$this->id;
+
+		dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG);
 		$result = $this->db->query($sql);
 		if ($result) {
 			$this->db->commit();
@@ -357,7 +357,7 @@ class AccountingAccount extends CommonObject
 		} else {
 			$this->error = $this->db->lasterror();
 			$this->db->rollback();
-			return - 1;
+			return -1;
 		}
 	}
 
@@ -370,13 +370,13 @@ class AccountingAccount extends CommonObject
     {
 		global $langs;
 
-		$sql = "(SELECT fk_code_ventilation FROM " . MAIN_DB_PREFIX . "facturedet";
-		$sql.= " WHERE fk_code_ventilation=" . $this->id . ")";
-		$sql.= "UNION";
-		$sql.= " (SELECT fk_code_ventilation FROM " . MAIN_DB_PREFIX . "facture_fourn_det";
-		$sql.= " WHERE fk_code_ventilation=" . $this->id . ")";
+		$sql = "(SELECT fk_code_ventilation FROM ".MAIN_DB_PREFIX."facturedet";
+		$sql .= " WHERE fk_code_ventilation=".$this->id.")";
+		$sql .= "UNION";
+		$sql .= " (SELECT fk_code_ventilation FROM ".MAIN_DB_PREFIX."facture_fourn_det";
+		$sql .= " WHERE fk_code_ventilation=".$this->id.")";
 
-		dol_syslog(get_class($this) . "::checkUsage sql=" . $sql, LOG_DEBUG);
+		dol_syslog(get_class($this)."::checkUsage sql=".$sql, LOG_DEBUG);
 		$resql = $this->db->query($sql);
 
 		if ($resql) {
@@ -389,7 +389,7 @@ class AccountingAccount extends CommonObject
 			}
 		} else {
 			$this->error = $this->db->lasterror();
-			return - 1;
+			return -1;
 		}
 	}
 
@@ -409,32 +409,32 @@ class AccountingAccount extends CommonObject
 		if ($result > 0) {
 			$this->db->begin();
 
-			if (! $error) {
-				$sql = "DELETE FROM " . MAIN_DB_PREFIX . "accounting_account";
-				$sql .= " WHERE rowid=" . $this->id;
+			if (!$error) {
+				$sql = "DELETE FROM ".MAIN_DB_PREFIX."accounting_account";
+				$sql .= " WHERE rowid=".$this->id;
 
-				dol_syslog(get_class($this) . "::delete sql=" . $sql);
+				dol_syslog(get_class($this)."::delete sql=".$sql);
 				$resql = $this->db->query($sql);
-				if (! $resql) {
-					$error ++;
-					$this->errors[] = "Error " . $this->db->lasterror();
+				if (!$resql) {
+					$error++;
+					$this->errors[] = "Error ".$this->db->lasterror();
 				}
 			}
 
 			// Commit or rollback
 			if ($error) {
 				foreach ($this->errors as $errmsg) {
-					dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR);
-					$this->error .= ($this->error ? ', ' . $errmsg : $errmsg);
+					dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
+					$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
 				}
 				$this->db->rollback();
-				return - 1 * $error;
+				return -1 * $error;
 			} else {
 				$this->db->commit();
 				return 1;
 			}
 		} else {
-			return - 1;
+			return -1;
 		}
     }
 
@@ -455,19 +455,19 @@ class AccountingAccount extends CommonObject
 		global $langs, $conf, $user;
 		require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
 
-		if (! empty($conf->dol_no_mouse_hover)) $notooltip=1;   // Force disable tooltips
+		if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips
 
 		$result = '';
 
-		$url = DOL_URL_ROOT . '/accountancy/admin/card.php?id=' . $this->id;
+		$url = DOL_URL_ROOT.'/accountancy/admin/card.php?id='.$this->id;
 
 		// Add param to save lastsearch_values or not
-		$add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
-		if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1;
-		if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
+		$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
+		if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
+		if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
 
 		$picto = 'billr';
-		$label='';
+		$label = '';
 
 		if (empty($this->labelshort) || $withcompletelabel == 1)
 		{
@@ -476,28 +476,28 @@ class AccountingAccount extends CommonObject
 			$labeltoshow = $this->labelshort;
 		}
 
-		$label = '<u>' . $langs->trans("ShowAccountingAccount") . '</u>';
-		if (! empty($this->account_number))
-			$label .= '<br><b>'.$langs->trans('AccountAccounting') . ':</b> ' . length_accountg($this->account_number);
-		if (! empty($labeltoshow))
-			$label .= '<br><b>'.$langs->trans('Label') . ':</b> ' . $labeltoshow;
-		if ($moretitle) $label.=' - '.$moretitle;
+		$label = '<u>'.$langs->trans("ShowAccountingAccount").'</u>';
+		if (!empty($this->account_number))
+			$label .= '<br><b>'.$langs->trans('AccountAccounting').':</b> '.length_accountg($this->account_number);
+		if (!empty($labeltoshow))
+			$label .= '<br><b>'.$langs->trans('Label').':</b> '.$labeltoshow;
+		if ($moretitle) $label .= ' - '.$moretitle;
 
-		$linkclose='';
+		$linkclose = '';
 		if (empty($notooltip))
 		{
-			if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
+			if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
 			{
-				$label=$langs->trans("ShowAccoutingAccount");
-				$linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
+				$label = $langs->trans("ShowAccoutingAccount");
+				$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
 			}
-			$linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"';
-			$linkclose.=' class="classfortooltip"';
+			$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
+			$linkclose .= ' class="classfortooltip"';
 		}
 
-		$linkstart='<a href="'.$url.'"';
-		$linkstart.=$linkclose.'>';
-		$linkend='</a>';
+		$linkstart = '<a href="'.$url.'"';
+		$linkstart .= $linkclose.'>';
+		$linkend = '</a>';
 
 		if ($nourl)
 		{
@@ -507,11 +507,11 @@ class AccountingAccount extends CommonObject
 		}
 
 		$label_link = length_accountg($this->account_number);
-		if ($withlabel) $label_link .= ' - ' . ($nourl ? '<span class="opacitymedium">' : '').$labeltoshow.($nourl ? '</span>' : '');
+		if ($withlabel) $label_link .= ' - '.($nourl ? '<span class="opacitymedium">' : '').$labeltoshow.($nourl ? '</span>' : '');
 
-		if ($withpicto) $result.=($linkstart.img_object(($notooltip?'':$label), $picto, ($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).$linkend);
+		if ($withpicto) $result .= ($linkstart.img_object(($notooltip ? '' : $label), $picto, ($notooltip ? '' : 'class="classfortooltip"'), 0, 0, $notooltip ? 0 : 1).$linkend);
 		if ($withpicto && $withpicto != 2) $result .= ' ';
-		if ($withpicto != 2) $result.=$linkstart . $label_link . $linkend;
+		if ($withpicto != 2) $result .= $linkstart.$label_link.$linkend;
 		return $result;
     }
 
@@ -524,10 +524,10 @@ class AccountingAccount extends CommonObject
     public function info($id)
     {
 		$sql = 'SELECT a.rowid, a.datec, a.fk_user_author, a.fk_user_modif, a.tms';
-		$sql .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as a';
-		$sql .= ' WHERE a.rowid = ' . $id;
+		$sql .= ' FROM '.MAIN_DB_PREFIX.'accounting_account as a';
+		$sql .= ' WHERE a.rowid = '.$id;
 
-		dol_syslog(get_class($this) . '::info sql=' . $sql);
+		dol_syslog(get_class($this).'::info sql='.$sql);
 		$result = $this->db->query($sql);
 
 		if ($result) {
@@ -578,11 +578,11 @@ class AccountingAccount extends CommonObject
 		if ($result > 0) {
 			$this->db->begin();
 
-			$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account ";
-			$sql .= "SET " . $fieldtouse . " = '0'";
-			$sql .= " WHERE rowid = " . $this->db->escape($id);
+			$sql = "UPDATE ".MAIN_DB_PREFIX."accounting_account ";
+			$sql .= "SET ".$fieldtouse." = '0'";
+			$sql .= " WHERE rowid = ".$this->db->escape($id);
 
-			dol_syslog(get_class($this) . "::account_desactivate " . $fieldtouse . " sql=" . $sql, LOG_DEBUG);
+			dol_syslog(get_class($this)."::account_desactivate ".$fieldtouse." sql=".$sql, LOG_DEBUG);
 			$result = $this->db->query($sql);
 
 			if ($result) {
@@ -591,10 +591,10 @@ class AccountingAccount extends CommonObject
 			} else {
 				$this->error = $this->db->lasterror();
 				$this->db->rollback();
-				return - 1;
+				return -1;
 			}
 		} else {
-			return - 1;
+			return -1;
 		}
 	}
 
@@ -620,11 +620,11 @@ class AccountingAccount extends CommonObject
             $fieldtouse = 'reconcilable';
         }
 
-		$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account ";
-		$sql .= "SET " . $fieldtouse . " = '1'";
-		$sql .= " WHERE rowid = " . $this->db->escape($id);
+		$sql = "UPDATE ".MAIN_DB_PREFIX."accounting_account ";
+		$sql .= "SET ".$fieldtouse." = '1'";
+		$sql .= " WHERE rowid = ".$this->db->escape($id);
 
-		dol_syslog(get_class($this) . "::account_activate " . $fieldtouse . " sql=" . $sql, LOG_DEBUG);
+		dol_syslog(get_class($this)."::account_activate ".$fieldtouse." sql=".$sql, LOG_DEBUG);
 		$result = $this->db->query($sql);
         if ($result) {
 			$this->db->commit();
@@ -632,7 +632,7 @@ class AccountingAccount extends CommonObject
         } else {
 			$this->error = $this->db->lasterror();
 			$this->db->rollback();
-			return - 1;
+			return -1;
         }
     }
 

+ 7 - 7
htdocs/accountancy/class/bookkeeping.class.php

@@ -361,20 +361,20 @@ class BookKeeping extends CommonObject
 				$sql .= ", '".$this->db->escape($this->doc_ref)."'";
 				$sql .= ", ".$this->fk_doc;
 				$sql .= ", ".$this->fk_docdet;
-				$sql .= ", ".(!empty($this->thirdparty_code)?("'".$this->db->escape($this->thirdparty_code)."'"):"NULL");
-				$sql .= ", ".(!empty($this->subledger_account)?("'".$this->db->escape($this->subledger_account)."'"):"NULL");
-				$sql .= ", ".(!empty($this->subledger_label)?("'".$this->db->escape($this->subledger_label)."'"):"NULL");
+				$sql .= ", ".(!empty($this->thirdparty_code) ? ("'".$this->db->escape($this->thirdparty_code)."'") : "NULL");
+				$sql .= ", ".(!empty($this->subledger_account) ? ("'".$this->db->escape($this->subledger_account)."'") : "NULL");
+				$sql .= ", ".(!empty($this->subledger_label) ? ("'".$this->db->escape($this->subledger_label)."'") : "NULL");
 				$sql .= ", '".$this->db->escape($this->numero_compte)."'";
-				$sql .= ", ".(!empty($this->label_operation)?("'".$this->db->escape($this->label_operation)."'"):"NULL");
+				$sql .= ", ".(!empty($this->label_operation) ? ("'".$this->db->escape($this->label_operation)."'") : "NULL");
 				$sql .= ", '".$this->db->escape($this->label_operation)."'";
 				$sql .= ", ".$this->debit;
 				$sql .= ", ".$this->credit;
 				$sql .= ", ".$this->montant;
-				$sql .= ", ".(!empty($this->sens)?("'".$this->db->escape($this->sens)."'"):"NULL");
+				$sql .= ", ".(!empty($this->sens) ? ("'".$this->db->escape($this->sens)."'") : "NULL");
 				$sql .= ", '".$this->db->escape($this->fk_user_author)."'";
 				$sql .= ", '".$this->db->idate($now)."'";
 				$sql .= ", '".$this->db->escape($this->code_journal)."'";
-				$sql .= ", ".(!empty($this->journal_label)?("'".$this->db->escape($this->journal_label)."'"):"NULL");
+				$sql .= ", ".(!empty($this->journal_label) ? ("'".$this->db->escape($this->journal_label)."'") : "NULL");
 				$sql .= ", ".$this->db->escape($this->piece_num);
 				$sql .= ", ".(!isset($this->entity) ? $conf->entity : $this->entity);
 				$sql .= ")";
@@ -1397,7 +1397,7 @@ class BookKeeping extends CommonObject
 		$sql = "DELETE";
 		$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element.$mode;
 		$sql .= " WHERE 1 = 1";
-		$sql.= dolSqlDateFilter('doc_date', 0, $delmonth, $delyear);
+		$sql .= dolSqlDateFilter('doc_date', 0, $delmonth, $delyear);
 		if (!empty($journal)) $sql .= " AND code_journal = '".$this->db->escape($journal)."'";
 		$sql .= " AND entity IN (".getEntity('accountancy').")";
 

+ 67 - 67
htdocs/accountancy/class/lettering.class.php

@@ -24,9 +24,9 @@
  * \brief 		File of class for lettering
  */
 
-include_once DOL_DOCUMENT_ROOT . "/accountancy/class/bookkeeping.class.php";
-include_once DOL_DOCUMENT_ROOT . "/societe/class/societe.class.php";
-include_once DOL_DOCUMENT_ROOT . "/core/lib/date.lib.php";
+include_once DOL_DOCUMENT_ROOT."/accountancy/class/bookkeeping.class.php";
+include_once DOL_DOCUMENT_ROOT."/societe/class/societe.class.php";
+include_once DOL_DOCUMENT_ROOT."/core/lib/date.lib.php";
 
 /**
  * Class Lettering
@@ -64,15 +64,15 @@ class Lettering extends BookKeeping
 		$sql = "SELECT DISTINCT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, bk.subledger_account, ";
 		$sql .= " bk.numero_compte , bk.label_compte, bk.debit , bk.credit, bk.montant ";
 		$sql .= " , bk.sens , bk.code_journal , bk.piece_num, bk.date_lettering, bu.url_id , bu.type ";
-		$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk";
-		$sql .= " LEFT JOIN  " . MAIN_DB_PREFIX . "bank_url as bu ON(bk.fk_doc = bu.fk_bank AND bu.type IN ('payment', 'payment_supplier') ) ";
+		$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as bk";
+		$sql .= " LEFT JOIN  ".MAIN_DB_PREFIX."bank_url as bu ON(bk.fk_doc = bu.fk_bank AND bu.type IN ('payment', 'payment_supplier') ) ";
 		$sql .= " WHERE ( ";
 		if ($object->code_compta != "")
-			$sql .= " bk.subledger_account = '" . $object->code_compta . "'  ";
+			$sql .= " bk.subledger_account = '".$object->code_compta."'  ";
 		if ($object->code_compta != "" && $object->code_compta_fournisseur != "")
 			$sql .= " OR ";
 		if ($object->code_compta_fournisseur != "")
-			$sql .= " bk.subledger_account = '" . $object->code_compta_fournisseur . "' ";
+			$sql .= " bk.subledger_account = '".$object->code_compta_fournisseur."' ";
 
 		$sql .= " ) AND (bk.date_lettering ='' OR bk.date_lettering IS NULL) ";
 		$sql .= "  AND (bk.lettering_code != '' OR bk.lettering_code IS NULL) ";
@@ -85,127 +85,127 @@ class Lettering extends BookKeeping
 		if ($resql) {
 			$num = $this->db->num_rows($resql);
 
-			while ($obj = $this->db->fetch_object($resql) ) {
+			while ($obj = $this->db->fetch_object($resql)) {
 				$ids = array();
 				$ids_fact = array();
 
 				if ($obj->type == 'payment_supplier')
 				{
 					$sql = 'SELECT DISTINCT bk.rowid, facf.ref, facf.ref_supplier, payf.fk_bank, facf.rowid as fact_id';
-					$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf ";
-					$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON  payfacf.fk_facturefourn=facf.rowid";
-					$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn as payf ON  payfacf.fk_paiementfourn=payf.rowid";
-					$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk ON (bk.fk_doc = payf.fk_bank AND bk.code_journal='" . $obj->code_journal . "')";
-					$sql .= " WHERE payfacf.fk_paiementfourn = '" . $obj->url_id . "' ";
+					$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn facf ";
+					$sql .= " INNER JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as payfacf ON  payfacf.fk_facturefourn=facf.rowid";
+					$sql .= " INNER JOIN ".MAIN_DB_PREFIX."paiementfourn as payf ON  payfacf.fk_paiementfourn=payf.rowid";
+					$sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_bookkeeping as bk ON (bk.fk_doc = payf.fk_bank AND bk.code_journal='".$obj->code_journal."')";
+					$sql .= " WHERE payfacf.fk_paiementfourn = '".$obj->url_id."' ";
 					$sql .= " AND facf.entity = ".$conf->entity;
-					$sql .= " AND code_journal IN (SELECT code FROM " . MAIN_DB_PREFIX . "accounting_journal WHERE nature=4 AND entity=".$conf->entity.") ";
+					$sql .= " AND code_journal IN (SELECT code FROM ".MAIN_DB_PREFIX."accounting_journal WHERE nature=4 AND entity=".$conf->entity.") ";
 					$sql .= " AND ( ";
 					if ($object->code_compta != "") {
-						$sql .= "  bk.subledger_account = '" . $object->code_compta . "'  ";
+						$sql .= "  bk.subledger_account = '".$object->code_compta."'  ";
 					}
 					if ($object->code_compta != "" && $object->code_compta_fournisseur != "") {
 						$sql .= "  OR  ";
 					}
 					if ($object->code_compta_fournisseur != "") {
-						$sql .= "   bk.subledger_account = '" . $object->code_compta_fournisseur . "' ";
+						$sql .= "   bk.subledger_account = '".$object->code_compta_fournisseur."' ";
 					}
 					$sql .= " )  ";
 
 					$resql2 = $this->db->query($sql);
 					if ($resql2) {
-						while ( $obj2 = $this->db->fetch_object($resql2) ) {
+						while ($obj2 = $this->db->fetch_object($resql2)) {
 							$ids[$obj2->rowid] = $obj2->rowid;
 							$ids_fact[] = $obj2->fact_id;
 						}
 					} else {
 						$this->errors[] = $this->db->lasterror;
-						return - 1;
+						return -1;
 					}
 					if (count($ids_fact)) {
 						$sql = 'SELECT bk.rowid, facf.ref, facf.ref_supplier ';
-						$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf ";
-						$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk ON(  bk.fk_doc = facf.rowid AND facf.rowid IN (" . implode(',', $ids_fact) . "))";
-						$sql .= " WHERE bk.code_journal IN (SELECT code FROM " . MAIN_DB_PREFIX . "accounting_journal WHERE nature=3 AND entity=".$conf->entity.") ";
+						$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn facf ";
+						$sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_bookkeeping as bk ON(  bk.fk_doc = facf.rowid AND facf.rowid IN (".implode(',', $ids_fact)."))";
+						$sql .= " WHERE bk.code_journal IN (SELECT code FROM ".MAIN_DB_PREFIX."accounting_journal WHERE nature=3 AND entity=".$conf->entity.") ";
 						$sql .= " AND facf.entity = ".$conf->entity;
 						$sql .= " AND ( ";
 						if ($object->code_compta != "") {
-							$sql .= " bk.subledger_account = '" . $object->code_compta . "'  ";
+							$sql .= " bk.subledger_account = '".$object->code_compta."'  ";
 						}
 						if ($object->code_compta != "" && $object->code_compta_fournisseur != "") {
 							$sql .= " OR ";
 						}
 						if ($object->code_compta_fournisseur != "") {
-							$sql .= " bk.subledger_account = '" . $object->code_compta_fournisseur . "' ";
+							$sql .= " bk.subledger_account = '".$object->code_compta_fournisseur."' ";
 						}
 						$sql .= ") ";
 
 						$resql2 = $this->db->query($sql);
 						if ($resql2) {
-							while ( $obj2 = $this->db->fetch_object($resql2) ) {
+							while ($obj2 = $this->db->fetch_object($resql2)) {
 								$ids[$obj2->rowid] = $obj2->rowid;
 							}
 						} else {
 							$this->errors[] = $this->db->lasterror;
-							return - 1;
+							return -1;
 						}
 					}
 				} elseif ($obj->type == 'payment') {
 					$sql = 'SELECT DISTINCT bk.rowid, fac.ref, fac.ref, pay.fk_bank, fac.rowid as fact_id';
-					$sql .= " FROM " . MAIN_DB_PREFIX . "facture fac ";
-					$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON  payfac.fk_facture=fac.rowid";
-					$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement as pay ON  payfac.fk_paiement=pay.rowid";
-					$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk ON (bk.fk_doc = pay.fk_bank AND bk.code_journal='" . $obj->code_journal . "')";
-					$sql .= " WHERE payfac.fk_paiement = '" . $obj->url_id . "' ";
-					$sql .= " AND bk.code_journal IN (SELECT code FROM " . MAIN_DB_PREFIX . "accounting_journal WHERE nature=4 AND entity=".$conf->entity.") ";
-					$sql .= " AND fac.entity IN (".getEntity('invoice', 0).")";// We don't share object for accountancy
+					$sql .= " FROM ".MAIN_DB_PREFIX."facture fac ";
+					$sql .= " INNER JOIN ".MAIN_DB_PREFIX."paiement_facture as payfac ON  payfac.fk_facture=fac.rowid";
+					$sql .= " INNER JOIN ".MAIN_DB_PREFIX."paiement as pay ON  payfac.fk_paiement=pay.rowid";
+					$sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_bookkeeping as bk ON (bk.fk_doc = pay.fk_bank AND bk.code_journal='".$obj->code_journal."')";
+					$sql .= " WHERE payfac.fk_paiement = '".$obj->url_id."' ";
+					$sql .= " AND bk.code_journal IN (SELECT code FROM ".MAIN_DB_PREFIX."accounting_journal WHERE nature=4 AND entity=".$conf->entity.") ";
+					$sql .= " AND fac.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy
 					$sql .= " AND ( ";
 					if ($object->code_compta != "") {
-						$sql .= "  bk.subledger_account = '" . $object->code_compta . "'  ";
+						$sql .= "  bk.subledger_account = '".$object->code_compta."'  ";
 					}
 					if ($object->code_compta != "" && $object->code_compta_fournisseur != "") {
 						$sql .= "  OR  ";
 					}
 					if ($object->code_compta_fournisseur != "") {
-						$sql .= "   bk.subledger_account = '" . $object->code_compta_fournisseur . "' ";
+						$sql .= "   bk.subledger_account = '".$object->code_compta_fournisseur."' ";
 					}
 					$sql .= " )  ";
 
 					$resql2 = $this->db->query($sql);
 					if ($resql2) {
-						while ( $obj2 = $this->db->fetch_object($resql2) ) {
+						while ($obj2 = $this->db->fetch_object($resql2)) {
 							$ids[$obj2->rowid] = $obj2->rowid;
 							$ids_fact[] = $obj2->fact_id;
 						}
 					} else {
 						$this->errors[] = $this->db->lasterror;
-						return - 1;
+						return -1;
 					}
 					if (count($ids_fact)) {
 						$sql = 'SELECT bk.rowid, fac.ref, fac.ref_supplier ';
-						$sql .= " FROM " . MAIN_DB_PREFIX . "facture fac ";
-						$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk ON(  bk.fk_doc = fac.rowid AND fac.rowid IN (" . implode(',', $ids_fact) . "))";
-						$sql .= " WHERE code_journal IN (SELECT code FROM " . MAIN_DB_PREFIX . "accounting_journal WHERE nature=2 AND entity=".$conf->entity.") ";
-						$sql .= " AND fac.entity IN (".getEntity('invoice', 0).")";// We don't share object for accountancy
+						$sql .= " FROM ".MAIN_DB_PREFIX."facture fac ";
+						$sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_bookkeeping as bk ON(  bk.fk_doc = fac.rowid AND fac.rowid IN (".implode(',', $ids_fact)."))";
+						$sql .= " WHERE code_journal IN (SELECT code FROM ".MAIN_DB_PREFIX."accounting_journal WHERE nature=2 AND entity=".$conf->entity.") ";
+						$sql .= " AND fac.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy
 						$sql .= " AND ( ";
 						if ($object->code_compta != "") {
-							$sql .= "  bk.subledger_account = '" . $object->code_compta . "'  ";
+							$sql .= "  bk.subledger_account = '".$object->code_compta."'  ";
 						}
 						if ($object->code_compta != "" && $object->code_compta_fournisseur != "") {
 							$sql .= "  OR  ";
 						}
 						if ($object->code_compta_fournisseur != "") {
-							$sql .= "   bk.subledger_account = '" . $object->code_compta_fournisseur . "' ";
+							$sql .= "   bk.subledger_account = '".$object->code_compta_fournisseur."' ";
 						}
 						$sql .= " )  ";
 
 						$resql2 = $this->db->query($sql);
 						if ($resql2) {
-							while ( $obj2 = $this->db->fetch_object($resql2) ) {
+							while ($obj2 = $this->db->fetch_object($resql2)) {
 								$ids[$obj2->rowid] = $obj2->rowid;
 							}
 						} else {
 							$this->errors[] = $this->db->lasterror;
-							return - 1;
+							return -1;
 						}
 					}
 				}
@@ -217,10 +217,10 @@ class Lettering extends BookKeeping
 		}
 		if ($error) {
 			foreach ($this->errors as $errmsg) {
-				dol_syslog(get_class($this) . "::" . __METHOD__ . $errmsg, LOG_ERR);
-				$this->error .= ($this->error ? ', ' . $errmsg : $errmsg);
+				dol_syslog(get_class($this)."::".__METHOD__.$errmsg, LOG_ERR);
+				$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
 			}
-			return - 1 * $error;
+			return -1 * $error;
 		} else {
 			return 1;
 		}
@@ -237,33 +237,33 @@ class Lettering extends BookKeeping
 		$error = 0;
 		$lettre = 'AAA';
 
-		dol_syslog(get_class($this) . "::" . __METHOD__, LOG_DEBUG);
+		dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
 
-		$sql = "SELECT DISTINCT lettering_code FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping WHERE ";
+		$sql = "SELECT DISTINCT lettering_code FROM ".MAIN_DB_PREFIX."accounting_bookkeeping WHERE ";
 		$sql .= " lettering_code != '' ORDER BY lettering_code DESC limit 1;  ";
 
 		$result = $this->db->query($sql);
 		if ($result) {
 			$obj = $this->db->fetch_object($result);
 			$lettre = (empty($obj->lettering_code) ? 'AAA' : $obj->lettering_code);
-			if (! empty($obj->lettering_code))
+			if (!empty($obj->lettering_code))
 				$lettre++;
 		} else {
-			$this->errors[] = 'Error' . $this->db->lasterror();
+			$this->errors[] = 'Error'.$this->db->lasterror();
 			$error++;
 		}
 
-		$sql = "SELECT SUM(ABS(debit)) as deb, SUM(ABS(credit)) as cred FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping WHERE ";
-		$sql .= " rowid IN (" . implode(',', $ids) . ") AND date_validated IS NULL ";
+		$sql = "SELECT SUM(ABS(debit)) as deb, SUM(ABS(credit)) as cred FROM ".MAIN_DB_PREFIX."accounting_bookkeeping WHERE ";
+		$sql .= " rowid IN (".implode(',', $ids).") AND date_validated IS NULL ";
 		$result = $this->db->query($sql);
 		if ($result) {
 			$obj = $this->db->fetch_object($result);
-			if (! (round(abs($obj->deb), 2) === round(abs($obj->cred), 2))) {
-				$this->errors[] = 'Total not exacts ' . round(abs($obj->deb), 2) . ' vs ' . round(abs($obj->cred), 2);
+			if (!(round(abs($obj->deb), 2) === round(abs($obj->cred), 2))) {
+				$this->errors[] = 'Total not exacts '.round(abs($obj->deb), 2).' vs '.round(abs($obj->cred), 2);
 				$error++;
 			}
 		} else {
-			$this->errors[] = 'Erreur sql' . $this->db->lasterror();
+			$this->errors[] = 'Erreur sql'.$this->db->lasterror();
 			$error++;
 		}
 
@@ -271,30 +271,30 @@ class Lettering extends BookKeeping
 
 		$now = dol_now();
 
-		if (! $error)
+		if (!$error)
 		{
-			$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_bookkeeping SET";
-			$sql .= " lettering_code='" . $lettre . "'";
-			$sql .= " , date_lettering = '" . $this->db->idate($now) . "'"; // todo correct date it's false
-			$sql .= "  WHERE rowid IN (" . implode(',', $ids) . ") AND date_validated IS NULL ";
+			$sql = "UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping SET";
+			$sql .= " lettering_code='".$lettre."'";
+			$sql .= " , date_lettering = '".$this->db->idate($now)."'"; // todo correct date it's false
+			$sql .= "  WHERE rowid IN (".implode(',', $ids).") AND date_validated IS NULL ";
 			$this->db->begin();
 
-			dol_syslog(get_class($this) . "::update sql=" . $sql, LOG_DEBUG);
+			dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG);
 			$resql = $this->db->query($sql);
-			if (! $resql) {
+			if (!$resql) {
 				$error++;
-				$this->errors[] = "Error " . $this->db->lasterror();
+				$this->errors[] = "Error ".$this->db->lasterror();
 			}
 		}
 
 		// Commit or rollback
 		if ($error) {
 			foreach ($this->errors as $errmsg) {
-				dol_syslog(get_class($this) . "::update " . $errmsg, LOG_ERR);
-				$this->error .= ($this->error ? ', ' . $errmsg : $errmsg);
+				dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
+				$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
 			}
 			$this->db->rollback();
-			return - 1 * $error;
+			return -1 * $error;
 		} else {
 			$this->db->commit();
 			return 1;

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

@@ -167,7 +167,7 @@ if ($action == 'validatehistory') {
 					$suggestedaccountingaccountfor = 'eecwithvat';
 				} elseif ($isSellerInEEC && $isBuyerInEEC && empty($objp->tva_intra)) {	// European intravat sale, without VAT intra community number
 					$objp->code_sell_p = $objp->code_sell;
-					$objp->aarowid_suggest = 0;		// There is a doubt, no automatic binding
+					$objp->aarowid_suggest = 0; // There is a doubt, no automatic binding
 					$suggestedaccountingaccountfor = 'eecwithoutvatnumber';
 				} elseif ($isSellerInEEC && $isBuyerInEEC) {          // European intravat sale
 					$objp->code_sell_p = $objp->code_sell_intra;

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

@@ -499,7 +499,7 @@ if ($result) {
 				$suggestedaccountingaccountfor = 'eecwithvat';
         	} elseif ($isSellerInEEC && $isBuyerInEEC && empty($objp->tva_intra)) {	// European intravat sale, without VAT intra community number
         		$objp->code_sell_p = $objp->code_sell;
-        		$objp->aarowid_suggest = $objp->aarowid;	// There is a doubt for this case. Is it an error on vat or we just forgot to fill vat number ?
+        		$objp->aarowid_suggest = $objp->aarowid; // There is a doubt for this case. Is it an error on vat or we just forgot to fill vat number ?
         		$suggestedaccountingaccountfor = 'eecwithoutvatnumber';
 			} elseif ($isSellerInEEC && $isBuyerInEEC) {          // European intravat sale
                 $objp->code_sell_p = $objp->code_sell_intra;
@@ -512,7 +512,7 @@ if ($result) {
             }
         }
 
-		if (! empty($objp->code_sell_p)) {
+		if (!empty($objp->code_sell_p)) {
 			// Value was defined previously
 		} else {
 			$code_sell_p_notset = 'color:orange';
@@ -595,7 +595,7 @@ if ($result) {
 		/*var_dump($suggestedid);
 		var_dump($objp->code_sell_p);
 		var_dump($objp->code_sell_l);*/
-		if (empty($suggestedid) && empty($objp->code_sell_p) && ! empty($objp->code_sell_l) && empty($conf->global->ACCOUNTANCY_DO_NOT_AUTOFILL_ACCOUNT_WITH_GENERIC))
+		if (empty($suggestedid) && empty($objp->code_sell_p) && !empty($objp->code_sell_l) && empty($conf->global->ACCOUNTANCY_DO_NOT_AUTOFILL_ACCOUNT_WITH_GENERIC))
 		{
 			if (empty($accountingaccount_codetotid_cache[$objp->code_sell_l]))
 			{
@@ -632,7 +632,7 @@ if ($result) {
 	print $db->error();
 }
 if ($db->type == 'mysqli') {
-	$db->query("SET SQL_BIG_SELECTS=0");  // Enable MAX_JOIN_SIZE limitation
+	$db->query("SET SQL_BIG_SELECTS=0"); // Enable MAX_JOIN_SIZE limitation
 }
 
 // Add code to auto check the box when we select an account

+ 2 - 2
htdocs/accountancy/index.php

@@ -90,10 +90,10 @@ if ($conf->accounting->enabled)
 
 	print load_fiche_titre($langs->trans("AccountancyArea"), $resultboxes['selectboxlist'], 'accountancy', 0, '', '', $showtutorial);
 
-    print '<div class="'.($helpisexpanded ? '' : 'hideobject').'" id="idfaq">'; 	// hideobject is to start hidden
+    print '<div class="'.($helpisexpanded ? '' : 'hideobject').'" id="idfaq">'; // hideobject is to start hidden
     print "<br>\n";
     print '<span class="opacitymedium">'.$langs->trans("AccountancyAreaDescIntro")."</span><br>\n";
-	print "<br>\n";print "<br>\n";
+	print "<br>\n"; print "<br>\n";
 
 	print load_fiche_titre('<span class="fa fa-calendar-check-o"></span> '.$langs->trans("AccountancyAreaDescActionOnce"), '', '')."\n";
 	print '<hr>';

+ 256 - 256
htdocs/accountancy/journal/bankjournal.php

@@ -31,37 +31,37 @@
  *  \brief      Page with bank journal
  */
 require '../../main.inc.php';
-require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/core/lib/bank.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
-require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
-require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
-require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php';
-require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php';
-require_once DOL_DOCUMENT_ROOT . '/compta/sociales/class/chargesociales.class.php';
-require_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php';
-require_once DOL_DOCUMENT_ROOT . '/don/class/don.class.php';
-require_once DOL_DOCUMENT_ROOT . '/don/class/paymentdonation.class.php';
-require_once DOL_DOCUMENT_ROOT . '/compta/tva/class/tva.class.php';
-require_once DOL_DOCUMENT_ROOT . '/salaries/class/paymentsalary.class.php';
-require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
-require_once DOL_DOCUMENT_ROOT . '/fourn/class/paiementfourn.class.php';
-require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
-require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.class.php';
-require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
-require_once DOL_DOCUMENT_ROOT . '/societe/class/client.class.php';
-require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
-require_once DOL_DOCUMENT_ROOT . '/expensereport/class/paymentexpensereport.class.php';
-require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/paymentvarious.class.php';
-require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php';
-require_once DOL_DOCUMENT_ROOT . '/loan/class/loan.class.php';
-require_once DOL_DOCUMENT_ROOT . '/loan/class/paymentloan.class.php';
-require_once DOL_DOCUMENT_ROOT . '/adherents/class/subscription.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
+require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
+require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
+require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
+require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
+require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
+require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
+require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
+require_once DOL_DOCUMENT_ROOT.'/don/class/paymentdonation.class.php';
+require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
+require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php';
+require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
+require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
+require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
+require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
+require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
+require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php';
+require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
+require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php';
+require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php';
+require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
+require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php';
+require_once DOL_DOCUMENT_ROOT.'/loan/class/paymentloan.class.php';
+require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php';
 
 // Load translation files required by the page
-$langs->loadLangs(array("companies","other","compta","banks","bills","donations","loan","accountancy","trips","salaries","hrm","members"));
+$langs->loadLangs(array("companies", "other", "compta", "banks", "bills", "donations", "loan", "accountancy", "trips", "salaries", "hrm", "members"));
 
 // Multi journal
 $id_journal = GETPOST('id_journal', 'int');
@@ -95,13 +95,13 @@ $pastmonth = strftime("%m", dol_now()) - 1;
 $pastmonthyear = $year_current;
 if ($pastmonth == 0) {
 	$pastmonth = 12;
-	$pastmonthyear --;
+	$pastmonthyear--;
 }
 
 $date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
 $date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
 
-if (! GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) // We define date_start and date_end, only if we did not submit the form
+if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) // We define date_start and date_end, only if we did not submit the form
 {
 	$date_start = dol_get_first_day($pastmonthyear, $pastmonth, false);
 	$date_end = dol_get_last_day($pastmonthyear, $pastmonth, false);
@@ -112,26 +112,26 @@ $sql .= " ba.courant, ba.ref as baref, ba.account_number, ba.fk_accountancy_jour
 $sql .= " soc.code_compta, soc.code_compta_fournisseur, soc.rowid as socid, soc.nom as name, soc.email as email, bu1.type as typeop_company,";
 $sql .= " u.accountancy_code, u.rowid as userid, u.lastname as lastname, u.firstname as firstname, u.email as useremail, bu2.type as typeop_user,";
 $sql .= " bu3.type as typeop_payment, bu4.type as typeop_payment_supplier";
-$sql .= " FROM " . MAIN_DB_PREFIX . "bank as b";
-$sql .= " JOIN " . MAIN_DB_PREFIX . "bank_account as ba on b.fk_account=ba.rowid";
-$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu1 ON bu1.fk_bank = b.rowid AND bu1.type='company'";
-$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu2 ON bu2.fk_bank = b.rowid AND bu2.type='user'";
-$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu3 ON bu3.fk_bank = b.rowid AND bu3.type='payment'";
-$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu4 ON bu4.fk_bank = b.rowid AND bu4.type='payment_supplier'";
-$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as soc on bu1.url_id=soc.rowid";
-$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "user as u on bu2.url_id=u.rowid";
-$sql .= " WHERE ba.fk_accountancy_journal=" . $id_journal;
-$sql .= ' AND b.amount != 0 AND ba.entity IN ('.getEntity('bank_account', 0).')';		// We don't share object for accountancy
+$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
+$sql .= " JOIN ".MAIN_DB_PREFIX."bank_account as ba on b.fk_account=ba.rowid";
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu1 ON bu1.fk_bank = b.rowid AND bu1.type='company'";
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu2 ON bu2.fk_bank = b.rowid AND bu2.type='user'";
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu3 ON bu3.fk_bank = b.rowid AND bu3.type='payment'";
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu4 ON bu4.fk_bank = b.rowid AND bu4.type='payment_supplier'";
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as soc on bu1.url_id=soc.rowid";
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on bu2.url_id=u.rowid";
+$sql .= " WHERE ba.fk_accountancy_journal=".$id_journal;
+$sql .= ' AND b.amount != 0 AND ba.entity IN ('.getEntity('bank_account', 0).')'; // We don't share object for accountancy
 if ($date_start && $date_end)
-	$sql .= " AND b.dateo >= '" . $db->idate($date_start) . "' AND b.dateo <= '" . $db->idate($date_end) . "'";
+	$sql .= " AND b.dateo >= '".$db->idate($date_start)."' AND b.dateo <= '".$db->idate($date_end)."'";
 // Already in bookkeeping or not
 if ($in_bookkeeping == 'already')
 {
-	$sql .= " AND (b.rowid IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab  WHERE ab.doc_type='bank') )";
+	$sql .= " AND (b.rowid IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab  WHERE ab.doc_type='bank') )";
 }
 if ($in_bookkeeping == 'notyet')
 {
-	$sql .= " AND (b.rowid NOT IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab  WHERE ab.doc_type='bank') )";
+	$sql .= " AND (b.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab  WHERE ab.doc_type='bank') )";
 }
 $sql .= " ORDER BY b.datev";
 //print $sql;
@@ -149,7 +149,7 @@ $paymentsalstatic = new PaymentSalary($db);
 $paymentexpensereportstatic = new PaymentExpenseReport($db);
 $paymentvariousstatic = new PaymentVarious($db);
 $paymentloanstatic = new PaymentLoan($db);
-$accountLinestatic=new AccountLine($db);
+$accountLinestatic = new AccountLine($db);
 $paymentsubscriptionstatic = new Subscription($db);
 
 $tmppayment = new Paiement($db);
@@ -171,20 +171,20 @@ if ($result) {
 	//print $sql;
 
 	// Variables
-	$account_supplier			= (($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER != "") ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : 'NotDefined');	// NotDefined is a reserved word
-	$account_customer			= (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER != "") ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : 'NotDefined');	// NotDefined is a reserved word
-	$account_employee			= (! empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT : 'NotDefined');	// NotDefined is a reserved word
-	$account_pay_vat			= (! empty($conf->global->ACCOUNTING_VAT_PAY_ACCOUNT) ? $conf->global->ACCOUNTING_VAT_PAY_ACCOUNT : 'NotDefined');	// NotDefined is a reserved word
-	$account_pay_donation		= (! empty($conf->global->DONATION_ACCOUNTINGACCOUNT) ? $conf->global->DONATION_ACCOUNTINGACCOUNT : 'NotDefined');	// NotDefined is a reserved word
-	$account_pay_subscription	= (! empty($conf->global->ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT) ? $conf->global->ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT : 'NotDefined');	// NotDefined is a reserved word
-	$account_transfer			= (! empty($conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH) ? $conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH : 'NotDefined');	// NotDefined is a reserved word
+	$account_supplier			= (($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER != "") ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : 'NotDefined'); // NotDefined is a reserved word
+	$account_customer			= (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER != "") ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : 'NotDefined'); // NotDefined is a reserved word
+	$account_employee			= (!empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT : 'NotDefined'); // NotDefined is a reserved word
+	$account_pay_vat = (!empty($conf->global->ACCOUNTING_VAT_PAY_ACCOUNT) ? $conf->global->ACCOUNTING_VAT_PAY_ACCOUNT : 'NotDefined'); // NotDefined is a reserved word
+	$account_pay_donation = (!empty($conf->global->DONATION_ACCOUNTINGACCOUNT) ? $conf->global->DONATION_ACCOUNTINGACCOUNT : 'NotDefined'); // NotDefined is a reserved word
+	$account_pay_subscription = (!empty($conf->global->ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT) ? $conf->global->ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT : 'NotDefined'); // NotDefined is a reserved word
+	$account_transfer = (!empty($conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH) ? $conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH : 'NotDefined'); // NotDefined is a reserved word
 
 	$tabcompany = array();
 	$tabuser = array();
-	$tabpay = array ();
-	$tabbq = array ();
-	$tabtp = array ();
-	$tabtype = array ();
+	$tabpay = array();
+	$tabbq = array();
+	$tabtp = array();
+	$tabtype = array();
 	$tabmoreinfo = array();
 
 	// Loop on each line into llx_bank table. For each line, we should get:
@@ -199,8 +199,8 @@ if ($result) {
 		$lineisapurchase = -1;
 		$lineisasale = -1;
 		// Old method to detect if it's a sale or purchase
-		if ($obj->label == '(SupplierInvoicePayment)' || $obj->label == '(SupplierInvoicePaymentBack)') $lineisapurchase=1;
-		if ($obj->label == '(CustomerInvoicePayment)' || $obj->label == '(CustomerInvoicePaymentBack)') $lineisasale=1;
+		if ($obj->label == '(SupplierInvoicePayment)' || $obj->label == '(SupplierInvoicePaymentBack)') $lineisapurchase = 1;
+		if ($obj->label == '(CustomerInvoicePayment)' || $obj->label == '(CustomerInvoicePaymentBack)') $lineisasale = 1;
 		// Try a more reliable method to detect if record is a supplier payment or a customer payment
 		if ($lineisapurchase < 0)
 		{
@@ -221,9 +221,9 @@ if ($result) {
 		if ($lineisapurchase > 0)
 			$compta_soc = (($obj->code_compta_fournisseur != "") ? $obj->code_compta_fournisseur : $account_supplier);
 		if ($lineisasale > 0)
-			$compta_soc = (! empty($obj->code_compta) ? $obj->code_compta : $account_customer);
+			$compta_soc = (!empty($obj->code_compta) ? $obj->code_compta : $account_customer);
 
-		$tabcompany[$obj->rowid] = array (
+		$tabcompany[$obj->rowid] = array(
 				'id' => $obj->socid,
 				'name' => $obj->name,
 				'code_compta' => $compta_soc,
@@ -231,9 +231,9 @@ if ($result) {
 		);
 
 		// Set accountancy code for user
-		$compta_user = (! empty($obj->accountancy_code) ? $obj->accountancy_code : $account_employee);
+		$compta_user = (!empty($obj->accountancy_code) ? $obj->accountancy_code : $account_employee);
 
-		$tabuser[$obj->rowid] = array (
+		$tabuser[$obj->rowid] = array(
 				'id' => $obj->userid,
 				'name' => dolGetFirstLastname($obj->firstname, $obj->lastname),
 				'lastname' => $obj->lastname,
@@ -244,8 +244,8 @@ if ($result) {
 
 		// Variable bookkeeping ($obj->rowid is Bank Id)
 		$tabpay[$obj->rowid]["date"] = $obj->do;
-		$tabpay[$obj->rowid]["type_payment"] = $obj->fk_type;		// CHQ, VIR, LIQ, CB, ...
-		$tabpay[$obj->rowid]["ref"] = $obj->label;					// By default. Not unique. May be changed later
+		$tabpay[$obj->rowid]["type_payment"] = $obj->fk_type; // CHQ, VIR, LIQ, CB, ...
+		$tabpay[$obj->rowid]["ref"] = $obj->label; // By default. Not unique. May be changed later
 		$tabpay[$obj->rowid]["fk_bank"] = $obj->rowid;
 		$tabpay[$obj->rowid]["bank_account_ref"] = $obj->baref;
 		$tabpay[$obj->rowid]["fk_bank_account"] = $obj->fk_account;
@@ -254,14 +254,14 @@ if ($result) {
 		} else {
 			$tabpay[$obj->rowid]["lib"] = dol_trunc($obj->label, 60);
 		}
-		$links = $object->get_url($obj->rowid);		// Get an array('url'=>, 'url_id'=>, 'label'=>, 'type'=> 'fk_bank'=> )
+		$links = $object->get_url($obj->rowid); // Get an array('url'=>, 'url_id'=>, 'label'=>, 'type'=> 'fk_bank'=> )
 
 		//var_dump($i);
 		//var_dump($tabpay);
 		//var_dump($tabcompany);
 
 		// By default
-		$tabpay[$obj->rowid]['type'] = 'unknown';	// Can be SOLD, miscellaneous entry, payment of patient, or any old record with no links in bank_url.
+		$tabpay[$obj->rowid]['type'] = 'unknown'; // Can be SOLD, miscellaneous entry, payment of patient, or any old record with no links in bank_url.
 		$tabtype[$obj->rowid] = 'unknown';
 		$tabmoreinfo[$obj->rowid] = array();
 
@@ -287,18 +287,18 @@ if ($result) {
 				}
 
 				if ($links[$key]['type'] == 'withdraw') {
-					$tabmoreinfo[$obj->rowid]['withdraw']=1;
+					$tabmoreinfo[$obj->rowid]['withdraw'] = 1;
 				}
 
 				if ($links[$key]['type'] == 'payment') {
 					$paymentstatic->id = $links[$key]['url_id'];
 					$paymentstatic->ref = $links[$key]['url_id'];
-					$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentstatic->getNomUrl(2, '', '');		// TODO Do not include list of invoice in tooltip, the dol_string_nohtmltag is ko with this
+					$tabpay[$obj->rowid]["lib"] .= ' '.$paymentstatic->getNomUrl(2, '', ''); // TODO Do not include list of invoice in tooltip, the dol_string_nohtmltag is ko with this
 					$tabpay[$obj->rowid]["paymentid"] = $paymentstatic->id;
 				} elseif ($links[$key]['type'] == 'payment_supplier') {
 					$paymentsupplierstatic->id = $links[$key]['url_id'];
 					$paymentsupplierstatic->ref = $links[$key]['url_id'];
-					$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsupplierstatic->getNomUrl(2);
+					$tabpay[$obj->rowid]["lib"] .= ' '.$paymentsupplierstatic->getNomUrl(2);
 					$tabpay[$obj->rowid]["paymentsupplierid"] = $paymentsupplierstatic->id;
 				} elseif ($links[$key]['type'] == 'company') {
 					$societestatic->id = $links[$key]['url_id'];
@@ -313,13 +313,13 @@ if ($result) {
 					$userstatic->firstname = $tabuser[$obj->rowid]['firstname'];
 					$userstatic->lastname = $tabuser[$obj->rowid]['lastname'];
 					if ($userstatic->id > 0) $tabpay[$obj->rowid]["soclib"] = $userstatic->getNomUrl(1, '', 30);
-					else $tabpay[$obj->rowid]["soclib"] = '???';	// Should not happen, but happens with old data when id of user was not saved on expense report payment.
+					else $tabpay[$obj->rowid]["soclib"] = '???'; // Should not happen, but happens with old data when id of user was not saved on expense report payment.
 					if ($compta_user) $tabtp[$obj->rowid][$compta_user] += $obj->amount;
 				} elseif ($links[$key]['type'] == 'sc') {
 					$chargestatic->id = $links[$key]['url_id'];
 					$chargestatic->ref = $links[$key]['url_id'];
 
-					$tabpay[$obj->rowid]["lib"] .= ' ' . $chargestatic->getNomUrl(2);
+					$tabpay[$obj->rowid]["lib"] .= ' '.$chargestatic->getNomUrl(2);
 					if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) {
 						if ($reg[1] == 'socialcontribution')
 							$reg[1] = 'SocialContribution';
@@ -332,13 +332,13 @@ if ($result) {
 					$tabpay[$obj->rowid]["paymentscid"] = $chargestatic->id;
 
 					$sqlmid = 'SELECT cchgsoc.accountancy_code';
-					$sqlmid .= " FROM " . MAIN_DB_PREFIX . "c_chargesociales cchgsoc ";
-					$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "chargesociales as chgsoc ON chgsoc.fk_type=cchgsoc.id";
-					$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementcharge as paycharg ON paycharg.fk_charge=chgsoc.rowid";
-					$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "bank_url as bkurl ON bkurl.url_id=paycharg.rowid";
-					$sqlmid .= " WHERE bkurl.fk_bank=" . $obj->rowid;
+					$sqlmid .= " FROM ".MAIN_DB_PREFIX."c_chargesociales cchgsoc ";
+					$sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."chargesociales as chgsoc ON chgsoc.fk_type=cchgsoc.id";
+					$sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."paiementcharge as paycharg ON paycharg.fk_charge=chgsoc.rowid";
+					$sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."bank_url as bkurl ON bkurl.url_id=paycharg.rowid";
+					$sqlmid .= " WHERE bkurl.fk_bank=".$obj->rowid;
 
-					dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
+					dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=".$sqlmid, LOG_DEBUG);
 					$resultmid = $db->query($sqlmid);
 					if ($resultmid) {
 						$objmid = $db->fetch_object($resultmid);
@@ -348,14 +348,14 @@ if ($result) {
 					$paymentdonstatic->id = $links[$key]['url_id'];
 					$paymentdonstatic->ref = $links[$key]['url_id'];
 					$paymentdonstatic->fk_donation = $links[$key]['url_id'];
-					$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentdonstatic->getNomUrl(2);
+					$tabpay[$obj->rowid]["lib"] .= ' '.$paymentdonstatic->getNomUrl(2);
 					$tabpay[$obj->rowid]["paymentdonationid"] = $paymentdonstatic->id;
 					$tabtp[$obj->rowid][$account_pay_donation] += $obj->amount;
 				} elseif ($links[$key]['type'] == 'member') {
 					$paymentsubscriptionstatic->id = $links[$key]['url_id'];
 					$paymentsubscriptionstatic->ref = $links[$key]['url_id'];
 					$paymentsubscriptionstatic->label = $links[$key]['label'];
-					$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsubscriptionstatic->getNomUrl(2);
+					$tabpay[$obj->rowid]["lib"] .= ' '.$paymentsubscriptionstatic->getNomUrl(2);
 					$tabpay[$obj->rowid]["paymentsubscriptionid"] = $paymentsubscriptionstatic->id;
 					$paymentsubscriptionstatic->fetch($paymentsubscriptionstatic->id);
 					$tabtp[$obj->rowid][$account_pay_subscription] += $obj->amount;
@@ -363,14 +363,14 @@ if ($result) {
 					$paymentvatstatic->id = $links[$key]['url_id'];
 					$paymentvatstatic->ref = $links[$key]['url_id'];
 					$paymentvatstatic->label = $links[$key]['label'];
-					$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2);
+					$tabpay[$obj->rowid]["lib"] .= ' '.$paymentvatstatic->getNomUrl(2);
 					$tabpay[$obj->rowid]["paymentvatid"] = $paymentvatstatic->id;
 					$tabtp[$obj->rowid][$account_pay_vat] += $obj->amount;
 				} elseif ($links[$key]['type'] == 'payment_salary') {
 					$paymentsalstatic->id = $links[$key]['url_id'];
 					$paymentsalstatic->ref = $links[$key]['url_id'];
 					$paymentsalstatic->label = $links[$key]['label'];
-					$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsalstatic->getNomUrl(2);
+					$tabpay[$obj->rowid]["lib"] .= ' '.$paymentsalstatic->getNomUrl(2);
 					$tabpay[$obj->rowid]["paymentsalid"] = $paymentsalstatic->id;
 				} elseif ($links[$key]['type'] == 'payment_expensereport') {
 					$paymentexpensereportstatic->id = $links[$key]['url_id'];
@@ -380,25 +380,25 @@ if ($result) {
 					$paymentvariousstatic->id = $links[$key]['url_id'];
 					$paymentvariousstatic->ref = $links[$key]['url_id'];
 					$paymentvariousstatic->label = $links[$key]['label'];
-					$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvariousstatic->getNomUrl(2);
+					$tabpay[$obj->rowid]["lib"] .= ' '.$paymentvariousstatic->getNomUrl(2);
 					$tabpay[$obj->rowid]["paymentvariousid"] = $paymentvariousstatic->id;
 					$paymentvariousstatic->fetch($paymentvariousstatic->id);
-					$account_various = (! empty($paymentvariousstatic->accountancy_code) ? $paymentvariousstatic->accountancy_code : 'NotDefined');	// NotDefined is a reserved word
-                    $account_subledger = (! empty($paymentvariousstatic->subledger_account) ? $paymentvariousstatic->subledger_account : '');	// NotDefined is a reserved word
+					$account_various = (!empty($paymentvariousstatic->accountancy_code) ? $paymentvariousstatic->accountancy_code : 'NotDefined'); // NotDefined is a reserved word
+                    $account_subledger = (!empty($paymentvariousstatic->subledger_account) ? $paymentvariousstatic->subledger_account : ''); // NotDefined is a reserved word
                     $tabpay[$obj->rowid]["account_various"] = $account_various;
                     $tabtp[$obj->rowid][$account_subledger] += $obj->amount;
 				} elseif ($links[$key]['type'] == 'payment_loan') {
 					$paymentloanstatic->id = $links[$key]['url_id'];
 					$paymentloanstatic->ref = $links[$key]['url_id'];
 					$paymentloanstatic->fk_loan = $links[$key]['url_id'];
-					$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentloanstatic->getNomUrl(2);
+					$tabpay[$obj->rowid]["lib"] .= ' '.$paymentloanstatic->getNomUrl(2);
 					$tabpay[$obj->rowid]["paymentloanid"] = $paymentloanstatic->id;
 					//$tabtp[$obj->rowid][$account_pay_loan] += $obj->amount;
 					$sqlmid = 'SELECT pl.amount_capital, pl.amount_insurance, pl.amount_interest, l.accountancy_account_capital, l.accountancy_account_insurance, l.accountancy_account_interest';
-					$sqlmid.= ' FROM '.MAIN_DB_PREFIX.'payment_loan as pl, '.MAIN_DB_PREFIX.'loan as l';
-					$sqlmid.= ' WHERE l.rowid = pl.fk_loan AND pl.fk_bank = '.$obj->rowid;
+					$sqlmid .= ' FROM '.MAIN_DB_PREFIX.'payment_loan as pl, '.MAIN_DB_PREFIX.'loan as l';
+					$sqlmid .= ' WHERE l.rowid = pl.fk_loan AND pl.fk_bank = '.$obj->rowid;
 
-					dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
+					dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=".$sqlmid, LOG_DEBUG);
 					$resultmid = $db->query($sqlmid);
 					if ($resultmid) {
 						$objmid = $db->fetch_object($resultmid);
@@ -408,7 +408,7 @@ if ($result) {
 					}
 				} elseif ($links[$key]['type'] == 'banktransfert') {
 					$accountLinestatic->fetch($links[$key]['url_id']);
-					$tabpay[$obj->rowid]["lib"] .= ' '.$langs->trans("BankTransfer").'- ' .$accountLinestatic ->getNomUrl(1);
+					$tabpay[$obj->rowid]["lib"] .= ' '.$langs->trans("BankTransfer").'- '.$accountLinestatic ->getNomUrl(1);
 					$tabtp[$obj->rowid][$account_transfer] += $obj->amount;
 					$bankaccountstatic->fetch($tabpay[$obj->rowid]['fk_bank_account']);
 					$tabpay[$obj->rowid]["soclib"] = $bankaccountstatic->getNomUrl(2);
@@ -420,14 +420,14 @@ if ($result) {
 
 		// If no links were found to know the amount on thirdparty, we try to guess it.
 		// This may happens on bank entries without the links lines to 'company'.
-		if (empty($tabtp[$obj->rowid]) && ! empty($tabmoreinfo[$obj->rowid]['withdraw']))	// If we dont find 'company' link because it is an old 'withdraw' record
+		if (empty($tabtp[$obj->rowid]) && !empty($tabmoreinfo[$obj->rowid]['withdraw']))	// If we dont find 'company' link because it is an old 'withdraw' record
 		{
 			foreach ($links as $key => $val) {
 				if ($links[$key]['type'] == 'payment') {
 					// Get thirdparty
 					$tmppayment->fetch($links[$key]['url_id']);
 					$arrayofamounts = $tmppayment->getAmountsArray();
-					foreach($arrayofamounts as $invoiceid => $amount)
+					foreach ($arrayofamounts as $invoiceid => $amount)
 					{
 						$tmpinvoice->fetch($invoiceid);
 						$tmpinvoice->fetch_thirdparty();
@@ -478,7 +478,7 @@ var_dump($tabtp);
 var_dump($tabtype);*/
 
 // Write bookkeeping
-if (! $error && $action == 'writebookkeeping') {
+if (!$error && $action == 'writebookkeeping') {
 	$now = dol_now();
 
 	$error = 0;
@@ -501,7 +501,7 @@ if (! $error && $action == 'writebookkeeping') {
 		var_dump($tabbq);exit;*/
 
 		// Bank
-		if (! $errorforline && is_array($tabbq[$key]))
+		if (!$errorforline && is_array($tabbq[$key]))
 		{
 			// Line into bank account
 			foreach ($tabbq[$key] as $k => $mt)
@@ -509,9 +509,9 @@ if (! $error && $action == 'writebookkeeping') {
 				if ($mt)
 				{
 					$reflabel = '';
-					if (! empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib']) . " - ";
-					$reflabel.= $langs->trans("Bank").' '.dol_string_nohtmltag($val['bank_account_ref']);
-					if (! empty($val['soclib'])) $reflabel .= " - " . dol_string_nohtmltag($val['soclib']);
+					if (!empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib'])." - ";
+					$reflabel .= $langs->trans("Bank").' '.dol_string_nohtmltag($val['bank_account_ref']);
+					if (!empty($val['soclib'])) $reflabel .= " - ".dol_string_nohtmltag($val['soclib']);
 
 					$bookkeeping = new BookKeeping($db);
 					$bookkeeping->doc_date = $val["date"];
@@ -528,7 +528,7 @@ if (! $error && $action == 'writebookkeeping') {
 					$bookkeeping->montant = $mt;
 					$bookkeeping->sens = ($mt >= 0) ? 'D' : 'C';
 					$bookkeeping->debit = ($mt >= 0 ? $mt : 0);
-					$bookkeeping->credit = ($mt < 0 ? - $mt : 0);
+					$bookkeeping->credit = ($mt < 0 ? -$mt : 0);
 					$bookkeeping->code_journal = $journal;
 					$bookkeeping->journal_label = $journal_label;
 					$bookkeeping->fk_user_author = $user->id;
@@ -562,7 +562,7 @@ if (! $error && $action == 'writebookkeeping') {
 		}
 
 		// Third party
-		if (! $errorforline)
+		if (!$errorforline)
 		{
 			if (is_array($tabtp[$key]))
 			{
@@ -571,14 +571,14 @@ if (! $error && $action == 'writebookkeeping') {
 					if ($mt)
 					{
 						$reflabel = '';
-						if (! empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib']) . ($val['soclib']?" - ":"");
+						if (!empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib']).($val['soclib'] ? " - " : "");
 						if ($tabtype[$key] == 'banktransfert')
 						{
-							$reflabel.= dol_string_nohtmltag($langs->transnoentitiesnoconv('TransitionalAccount').' '.$account_transfer);
+							$reflabel .= dol_string_nohtmltag($langs->transnoentitiesnoconv('TransitionalAccount').' '.$account_transfer);
 						}
 						else
 						{
-							$reflabel.= dol_string_nohtmltag($val['soclib']);
+							$reflabel .= dol_string_nohtmltag($val['soclib']);
 						}
 
 						$bookkeeping = new BookKeeping($db);
@@ -590,7 +590,7 @@ if (! $error && $action == 'writebookkeeping') {
 						$bookkeeping->label_operation = $reflabel;
 						$bookkeeping->montant = $mt;
 						$bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
-						$bookkeeping->debit = ($mt < 0 ? - $mt : 0);
+						$bookkeeping->debit = ($mt < 0 ? -$mt : 0);
 						$bookkeeping->credit = ($mt >= 0) ? $mt : 0;
 						$bookkeeping->code_journal = $journal;
 						$bookkeeping->journal_label = $journal_label;
@@ -598,15 +598,15 @@ if (! $error && $action == 'writebookkeeping') {
 						$bookkeeping->date_creation = $now;
 
 						if ($tabtype[$key] == 'payment') {	// If payment is payment of customer invoice, we get ref of invoice
-							$bookkeeping->subledger_account = $k;							// For payment, the subledger account is stored as $key of $tabtp
-							$bookkeeping->subledger_label = $tabcompany[$key]['name'];		// $tabcompany is defined only if we are sure there is 1 thirdparty for the bank transaction
+							$bookkeeping->subledger_account = $k; // For payment, the subledger account is stored as $key of $tabtp
+							$bookkeeping->subledger_label = $tabcompany[$key]['name']; // $tabcompany is defined only if we are sure there is 1 thirdparty for the bank transaction
 							$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
 
 							$accountingaccount->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER, true);
 							$bookkeeping->label_compte = $accountingaccount->label;
 						} elseif ($tabtype[$key] == 'payment_supplier') {	// If payment is payment of supplier invoice, we get ref of invoice
-							$bookkeeping->subledger_account = $k;				   			// For payment, the subledger account is stored as $key of $tabtp
-							$bookkeeping->subledger_label = $tabcompany[$key]['name'];		// $tabcompany is defined only if we are sure there is 1 thirdparty for the bank transaction
+							$bookkeeping->subledger_account = $k; // For payment, the subledger account is stored as $key of $tabtp
+							$bookkeeping->subledger_label = $tabcompany[$key]['name']; // $tabcompany is defined only if we are sure there is 1 thirdparty for the bank transaction
 							$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER;
 
 							$accountingaccount->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER, true);
@@ -715,8 +715,8 @@ if (! $error && $action == 'writebookkeeping') {
 					if ($mt)
 					{
 						$reflabel = '';
-						if (! empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib']) . " - ";
-						$reflabel.= dol_string_nohtmltag('WaitingAccount');
+						if (!empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib'])." - ";
+						$reflabel .= dol_string_nohtmltag('WaitingAccount');
 
 						$bookkeeping = new BookKeeping($db);
 						$bookkeeping->doc_date = $val["date"];
@@ -726,7 +726,7 @@ if (! $error && $action == 'writebookkeeping') {
 						$bookkeeping->fk_docdet = $val["fk_bank"];
 						$bookkeeping->montant = $mt;
 						$bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
-						$bookkeeping->debit = ($mt < 0 ? - $mt : 0);
+						$bookkeeping->debit = ($mt < 0 ? -$mt : 0);
 						$bookkeeping->credit = ($mt >= 0) ? $mt : 0;
 						$bookkeeping->code_journal = $journal;
 						$bookkeeping->journal_label = $journal_label;
@@ -767,7 +767,7 @@ if (! $error && $action == 'writebookkeeping') {
 			setEventMessages('Try to insert a non balanced transaction in book for '.$ref.'. Canceled. Surely a bug.', null, 'errors');
 		}
 
-		if (! $errorforline)
+		if (!$errorforline)
 		{
 			$db->commit();
 		}
@@ -776,11 +776,11 @@ if (! $error && $action == 'writebookkeeping') {
 			//print 'KO for line '.$key.' '.$error.'<br>';
 			$db->rollback();
 
-			$MAXNBERRORS=5;
+			$MAXNBERRORS = 5;
 			if ($error >= $MAXNBERRORS)
 			{
 				setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped").' (>'.$MAXNBERRORS.')', null, 'errors');
-				break;  // Break in the foreach
+				break; // Break in the foreach
 			}
 		}
 	}
@@ -802,15 +802,15 @@ if (! $error && $action == 'writebookkeeping') {
 	// Must reload data, so we make a redirect
 	if (count($tabpay) != $error)
 	{
-		$param='id_journal='.$id_journal;
-		$param.='&date_startday='.$date_startday;
-		$param.='&date_startmonth='.$date_startmonth;
-		$param.='&date_startyear='.$date_startyear;
-		$param.='&date_endday='.$date_endday;
-		$param.='&date_endmonth='.$date_endmonth;
-		$param.='&date_endyear='.$date_endyear;
-		$param.='&in_bookkeeping='.$in_bookkeeping;
-		header("Location: ".$_SERVER['PHP_SELF'].($param?'?'.$param:''));
+		$param = 'id_journal='.$id_journal;
+		$param .= '&date_startday='.$date_startday;
+		$param .= '&date_startmonth='.$date_startmonth;
+		$param .= '&date_startyear='.$date_startyear;
+		$param .= '&date_endday='.$date_endday;
+		$param .= '&date_endmonth='.$date_endmonth;
+		$param .= '&date_endyear='.$date_endyear;
+		$param .= '&in_bookkeeping='.$in_bookkeeping;
+		header("Location: ".$_SERVER['PHP_SELF'].($param ? '?'.$param : ''));
 		exit;
 	}
 }
@@ -823,20 +823,20 @@ if ($action == 'exportcsv') {		// ISO and not UTF8 !
 
 	$filename = 'journal';
 	$type_export = 'journal';
-	include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
+	include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php';
 
 	// CSV header line
-	print '"' . $langs->transnoentitiesnoconv("BankId").'"' . $sep;
-	print '"' . $langs->transnoentitiesnoconv("Date") . '"' . $sep;
-	print '"' . $langs->transnoentitiesnoconv("PaymentMode") . '"' . $sep;
-	print '"' . $langs->transnoentitiesnoconv("AccountAccounting") . '"' . $sep;
-	print '"' . $langs->transnoentitiesnoconv("LedgerAccount") . '"' . $sep;
-	print '"' . $langs->transnoentitiesnoconv("SubledgerAccount") . '"' . $sep;
-	print '"' . $langs->transnoentitiesnoconv("Label"). '"' . $sep;
-	print '"' . $langs->transnoentitiesnoconv("Debit") . '"' . $sep;
-	print '"' . $langs->transnoentitiesnoconv("Credit") . '"' . $sep;
-	print '"' . $langs->transnoentitiesnoconv("Journal")  . '"' . $sep;
-	print '"' . $langs->transnoentitiesnoconv("Note")  . '"' . $sep;
+	print '"'.$langs->transnoentitiesnoconv("BankId").'"'.$sep;
+	print '"'.$langs->transnoentitiesnoconv("Date").'"'.$sep;
+	print '"'.$langs->transnoentitiesnoconv("PaymentMode").'"'.$sep;
+	print '"'.$langs->transnoentitiesnoconv("AccountAccounting").'"'.$sep;
+	print '"'.$langs->transnoentitiesnoconv("LedgerAccount").'"'.$sep;
+	print '"'.$langs->transnoentitiesnoconv("SubledgerAccount").'"'.$sep;
+	print '"'.$langs->transnoentitiesnoconv("Label").'"'.$sep;
+	print '"'.$langs->transnoentitiesnoconv("Debit").'"'.$sep;
+	print '"'.$langs->transnoentitiesnoconv("Credit").'"'.$sep;
+	print '"'.$langs->transnoentitiesnoconv("Journal").'"'.$sep;
+	print '"'.$langs->transnoentitiesnoconv("Note").'"'.$sep;
 	print "\n";
 
 	foreach ($tabpay as $key => $val)
@@ -850,21 +850,21 @@ if ($action == 'exportcsv') {		// ISO and not UTF8 !
 			if ($mt)
 			{
 				$reflabel = '';
-				if (! empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib']) . " - ";
-				$reflabel.= $langs->trans("Bank").' '.dol_string_nohtmltag($val['bank_account_ref']);
-				if (! empty($val['soclib'])) $reflabel .= " - " . dol_string_nohtmltag($val['soclib']);
-
-				print '"' . $key . '"' . $sep;
-				print '"' . $date . '"' . $sep;
-				print '"' . $val["type_payment"] . '"' . $sep;
-				print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
-				print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
-				print "  " . $sep;
-				print '"' . $reflabel . '"' . $sep;
-				print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
-				print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
-				print '"' . $journal . '"' . $sep;
-				print '"' . dol_string_nohtmltag($ref) . '"' . $sep;
+				if (!empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib'])." - ";
+				$reflabel .= $langs->trans("Bank").' '.dol_string_nohtmltag($val['bank_account_ref']);
+				if (!empty($val['soclib'])) $reflabel .= " - ".dol_string_nohtmltag($val['soclib']);
+
+				print '"'.$key.'"'.$sep;
+				print '"'.$date.'"'.$sep;
+				print '"'.$val["type_payment"].'"'.$sep;
+				print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
+				print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
+				print "  ".$sep;
+				print '"'.$reflabel.'"'.$sep;
+				print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep;
+				print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep;
+				print '"'.$journal.'"'.$sep;
+				print '"'.dol_string_nohtmltag($ref).'"'.$sep;
 				print "\n";
 			}
 		}
@@ -875,37 +875,37 @@ if ($action == 'exportcsv') {		// ISO and not UTF8 !
 				if ($mt)
 				{
 					$reflabel = '';
-					if (! empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib']) . ($val['soclib']?" - ":"");
+					if (!empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib']).($val['soclib'] ? " - " : "");
 					if ($tabtype[$key] == 'banktransfert')
 					{
-						$reflabel.= dol_string_nohtmltag($langs->transnoentitiesnoconv('TransitionalAccount').' '.$account_transfer);
+						$reflabel .= dol_string_nohtmltag($langs->transnoentitiesnoconv('TransitionalAccount').' '.$account_transfer);
 					}
 					else
 					{
-						$reflabel.= dol_string_nohtmltag($val['soclib']);
+						$reflabel .= dol_string_nohtmltag($val['soclib']);
 					}
 
-					print '"' . $key . '"' . $sep;
-					print '"' . $date . '"' . $sep;
-					print '"' . $val["type_payment"] . '"' . $sep;
-					print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
+					print '"'.$key.'"'.$sep;
+					print '"'.$date.'"'.$sep;
+					print '"'.$val["type_payment"].'"'.$sep;
+					print '"'.length_accounta(html_entity_decode($k)).'"'.$sep;
 					if ($tabtype[$key] == 'payment_supplier') {
-						print '"' . $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER . '"' . $sep;
-					} elseif($tabtype[$key] == 'payment') {
-						print '"' . $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER . '"' . $sep;
-					} elseif($tabtype[$key] == 'payment_expensereport') {
-						print '"' . $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT . '"' . $sep;
-					} elseif($tabtype[$key] == 'payment_salary') {
-						print '"' . $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT . '"' . $sep;
+						print '"'.$conf->global->ACCOUNTING_ACCOUNT_SUPPLIER.'"'.$sep;
+					} elseif ($tabtype[$key] == 'payment') {
+						print '"'.$conf->global->ACCOUNTING_ACCOUNT_CUSTOMER.'"'.$sep;
+					} elseif ($tabtype[$key] == 'payment_expensereport') {
+						print '"'.$conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT.'"'.$sep;
+					} elseif ($tabtype[$key] == 'payment_salary') {
+						print '"'.$conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT.'"'.$sep;
 					} else {
-						print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
+						print '"'.length_accounta(html_entity_decode($k)).'"'.$sep;
 					}
-					print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
-					print '"' . $reflabel . '"' . $sep;
-					print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
-					print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
-					print '"' . $journal . '"' . $sep;
-					print '"' . dol_string_nohtmltag($ref) . '"' . $sep;
+					print '"'.length_accounta(html_entity_decode($k)).'"'.$sep;
+					print '"'.$reflabel.'"'.$sep;
+					print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep;
+					print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep;
+					print '"'.$journal.'"'.$sep;
+					print '"'.dol_string_nohtmltag($ref).'"'.$sep;
 					print "\n";
 				}
 			}
@@ -914,20 +914,20 @@ if ($action == 'exportcsv') {		// ISO and not UTF8 !
 				if ($mt)
 				{
 					$reflabel = '';
-					if (! empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib']) . " - ";
-					$reflabel.= dol_string_nohtmltag('WaitingAccount');
-
-					print '"' . $key . '"' . $sep;
-					print '"' . $date . '"' . $sep;
-					print '"' . $val["type_payment"] . '"' . $sep;
-					print '"' . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . '"' . $sep;
-					print '"' . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . '"' . $sep;
-					print "" . $sep;
-					print '"' . $reflabel . '"' . $sep;
-					print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
-					print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
-					print '"' . $journal . '"' . $sep;
-					print '"' . dol_string_nohtmltag($ref) . '"' . $sep;
+					if (!empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib'])." - ";
+					$reflabel .= dol_string_nohtmltag('WaitingAccount');
+
+					print '"'.$key.'"'.$sep;
+					print '"'.$date.'"'.$sep;
+					print '"'.$val["type_payment"].'"'.$sep;
+					print '"'.length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE).'"'.$sep;
+					print '"'.length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE).'"'.$sep;
+					print "".$sep;
+					print '"'.$reflabel.'"'.$sep;
+					print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep;
+					print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep;
+					print '"'.$journal.'"'.$sep;
+					print '"'.dol_string_nohtmltag($ref).'"'.$sep;
 					print "\n";
 				}
 			}
@@ -954,16 +954,16 @@ if (empty($action) || $action == 'view') {
 
 	llxHeader('', $langs->trans("FinanceJournal"));
 
-	$nom = $langs->trans("FinanceJournal") . ' | ' . $accountingjournalstatic->getNomUrl(0, 1, 1, '', 1);
-	$builddate=dol_now();
+	$nom = $langs->trans("FinanceJournal").' | '.$accountingjournalstatic->getNomUrl(0, 1, 1, '', 1);
+	$builddate = dol_now();
 	//$description = $langs->trans("DescFinanceJournal") . '<br>';
-	$description.= $langs->trans("DescJournalOnlyBindedVisible").'<br>';
+	$description .= $langs->trans("DescJournalOnlyBindedVisible").'<br>';
 
-	$listofchoices=array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger"));
-    $period = $form->selectDate($date_start?$date_start:-1, 'date_start', 0, 0, 0, '', 1, 0) . ' - ' . $form->selectDate($date_end?$date_end:-1, 'date_end', 0, 0, 0, '', 1, 0);
-    $period .= ' -  ' .$langs->trans("JournalizationInLedgerStatus").' '. $form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
+	$listofchoices = array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger"));
+    $period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0);
+    $period .= ' -  '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
 
-	$varlink = 'id_journal=' . $id_journal;
+	$varlink = 'id_journal='.$id_journal;
 
 	journalHead($nom, '', $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink);
 
@@ -994,15 +994,15 @@ if (empty($action) || $action == 'view') {
 
 	print '<div class="tabsAction tabsActionNoBottom">';
 
-	if (! empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) print '<input type="button" class="butAction" name="exportcsv" value="' . $langs->trans("ExportDraftJournal") . '" onclick="launch_export();" />';
+	if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />';
 
 	if (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == "") || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1'
 	    || ($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == "") || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1') {
-	    print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="' . $langs->trans("WriteBookKeeping") . '" />';
+	    print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="'.$langs->trans("WriteBookKeeping").'" />';
 	}
 	else {
-	    if ($in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="writebookkeeping" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />';
-        else print '<a class="butActionRefused classfortooltip" name="writebookkeeping">' . $langs->trans("WriteBookKeeping") . '</a>';
+	    if ($in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans("WriteBookKeeping").'" onclick="writebookkeeping();" />';
+        else print '<a class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans("WriteBookKeeping").'</a>';
 	}
 
 	print '</div>';
@@ -1033,14 +1033,14 @@ if (empty($action) || $action == 'view') {
 	print '<div class="div-table-responsive">';
 	print "<table class=\"noborder\" width=\"100%\">";
 	print "<tr class=\"liste_titre\">";
-	print "<td>" . $langs->trans("Date") . "</td>";
-	print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("ObjectsRef") . ")</td>";
-	print "<td>" . $langs->trans("AccountAccounting") . "</td>";
-	print "<td>" . $langs->trans("SubledgerAccount") . "</td>";
-	print "<td>" . $langs->trans("LabelOperation") . "</td>";
-	print '<td class="center">' . $langs->trans("PaymentMode") . "</td>";
-	print '<td class="right">' . $langs->trans("Debit") . "</td>";
-	print '<td class="right">' . $langs->trans("Credit") . "</td>";
+	print "<td>".$langs->trans("Date")."</td>";
+	print "<td>".$langs->trans("Piece").' ('.$langs->trans("ObjectsRef").")</td>";
+	print "<td>".$langs->trans("AccountAccounting")."</td>";
+	print "<td>".$langs->trans("SubledgerAccount")."</td>";
+	print "<td>".$langs->trans("LabelOperation")."</td>";
+	print '<td class="center">'.$langs->trans("PaymentMode")."</td>";
+	print '<td class="right">'.$langs->trans("Debit")."</td>";
+	print '<td class="right">'.$langs->trans("Credit")."</td>";
 	print "</tr>\n";
 
 	$r = '';
@@ -1057,15 +1057,15 @@ if (empty($action) || $action == 'view') {
 			if ($mt)
 			{
 				$reflabel = '';
-				if (! empty($val['lib'])) $reflabel .= $val['lib'] . " - ";
-				$reflabel.= $langs->trans("Bank").' '.$val['bank_account_ref'];
-				if (! empty($val['soclib'])) $reflabel .= " - " . $val['soclib'];
+				if (!empty($val['lib'])) $reflabel .= $val['lib']." - ";
+				$reflabel .= $langs->trans("Bank").' '.$val['bank_account_ref'];
+				if (!empty($val['soclib'])) $reflabel .= " - ".$val['soclib'];
 
 				//var_dump($tabpay[$key]);
 				print '<!-- Bank bank.rowid='.$key.' type='.$tabpay[$key]['type'].' ref='.$tabpay[$key]['ref'].'-->';
 				print '<tr class="oddeven">';
-				print "<td>" . $date . "</td>";
-				print "<td>" . $ref . "</td>";
+				print "<td>".$date."</td>";
+				print "<td>".$ref."</td>";
 				// Ledger account
 				print "<td>";
 				$accounttoshow = length_accountg($k);
@@ -1087,9 +1087,9 @@ if (empty($action) || $action == 'view') {
 				print "<td>";
 				print $reflabel;
 				print "</td>";
-				print '<td class="center">' . $val["type_payment"] . "</td>";
-				print '<td class="right nowraponall">' . ($mt >= 0 ? price($mt) : '') . "</td>";
-				print '<td class="right nowraponall">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
+				print '<td class="center">'.$val["type_payment"]."</td>";
+				print '<td class="right nowraponall">'.($mt >= 0 ? price($mt) : '')."</td>";
+				print '<td class="right nowraponall">'.($mt < 0 ? price(-$mt) : '')."</td>";
 				print "</tr>";
 			}
 		}
@@ -1100,20 +1100,20 @@ if (empty($action) || $action == 'view') {
 				if ($mt)
 				{
 					$reflabel = '';
-					if (! empty($val['lib'])) $reflabel .= $val['lib'] . ($val['soclib']?" - ":"");
+					if (!empty($val['lib'])) $reflabel .= $val['lib'].($val['soclib'] ? " - " : "");
 					if ($tabtype[$key] == 'banktransfert')
 					{
-						$reflabel.= $langs->trans('TransitionalAccount').' '.$account_transfer;
+						$reflabel .= $langs->trans('TransitionalAccount').' '.$account_transfer;
 					}
 					else
 					{
-						$reflabel.= $val['soclib'];
+						$reflabel .= $val['soclib'];
 					}
 
 					print '<!-- Thirdparty bank.rowid='.$key.' -->';
 					print '<tr class="oddeven">';
-					print "<td>" . $date . "</td>";
-					print "<td>" . $ref . "</td>";
+					print "<td>".$date."</td>";
+					print "<td>".$ref."</td>";
 					// Ledger account
 					print "<td>";
 					$account_ledger = $k;
@@ -1137,19 +1137,19 @@ if (empty($action) || $action == 'view') {
 							}
 							else
 							{
-								print '<span class="warning">'.$langs->trans('UnknownAccountForThirdparty', length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE)).'</span>';	// We will use a waiting account
+								print '<span class="warning">'.$langs->trans('UnknownAccountForThirdparty', length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE)).'</span>'; // We will use a waiting account
 							}
 						}
 						else
 						{
 							// We will refuse writing
-							$errorstring='UnknownAccountForThirdpartyBlocking';
-							if ($tabtype[$key] == 'payment')				$errorstring='MainAccountForCustomersNotDefined';
-							if ($tabtype[$key] == 'payment_supplier')		$errorstring='MainAccountForSuppliersNotDefined';
-							if ($tabtype[$key] == 'payment_expensereport')	$errorstring='MainAccountForUsersNotDefined';
-							if ($tabtype[$key] == 'payment_salary')			$errorstring='MainAccountForUsersNotDefined';
-							if ($tabtype[$key] == 'payment_vat')			$errorstring='MainAccountForVatPaymentNotDefined';
-							if ($tabtype[$key] == 'member')					$errorstring='MainAccountForSubscriptionPaymentNotDefined';
+							$errorstring = 'UnknownAccountForThirdpartyBlocking';
+							if ($tabtype[$key] == 'payment')				$errorstring = 'MainAccountForCustomersNotDefined';
+							if ($tabtype[$key] == 'payment_supplier')		$errorstring = 'MainAccountForSuppliersNotDefined';
+							if ($tabtype[$key] == 'payment_expensereport')	$errorstring = 'MainAccountForUsersNotDefined';
+							if ($tabtype[$key] == 'payment_salary')			$errorstring = 'MainAccountForUsersNotDefined';
+							if ($tabtype[$key] == 'payment_vat')			$errorstring = 'MainAccountForVatPaymentNotDefined';
+							if ($tabtype[$key] == 'member')					$errorstring = 'MainAccountForSubscriptionPaymentNotDefined';
 							print '<span class="error">'.$langs->trans($errorstring).'</span>';
 						}
 					}
@@ -1169,7 +1169,7 @@ if (empty($action) || $action == 'view') {
 								var_dump($tabtype[$key]);
 								var_dump($tabbq[$key]);*/
 								//print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>';
-								if (! empty($tabcompany[$key]['code_compta']))
+								if (!empty($tabcompany[$key]['code_compta']))
 								{
 									if (in_array($tabtype[$key], array('payment_various'))) {
 										// For such case, if subledger is not defined, we won't use subledger accounts.
@@ -1187,10 +1187,10 @@ if (empty($action) || $action == 'view') {
 						}
 					}
 					print "</td>";
-					print "<td>" . $reflabel . "</td>";
-					print '<td class="center">' . $val["type_payment"] . "</td>";
-					print '<td class="right nowraponall">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
-					print '<td class="right nowraponall">' . ($mt >= 0 ? price($mt) : '') . "</td>";
+					print "<td>".$reflabel."</td>";
+					print '<td class="center">'.$val["type_payment"]."</td>";
+					print '<td class="right nowraponall">'.($mt < 0 ? price(-$mt) : '')."</td>";
+					print '<td class="right nowraponall">'.($mt >= 0 ? price($mt) : '')."</td>";
 					print "</tr>";
 				}
 			}
@@ -1199,13 +1199,13 @@ if (empty($action) || $action == 'view') {
 				if ($mt)
 				{
 					$reflabel = '';
-					if (! empty($val['lib'])) $reflabel .= $val['lib'] . " - ";
-					$reflabel.= 'WaitingAccount';
+					if (!empty($val['lib'])) $reflabel .= $val['lib']." - ";
+					$reflabel .= 'WaitingAccount';
 
 					print '<!-- Wait bank.rowid='.$key.' -->';
 					print '<tr class="oddeven">';
-					print "<td>" . $date . "</td>";
-					print "<td>" . $ref . "</td>";
+					print "<td>".$date."</td>";
+					print "<td>".$ref."</td>";
 					// Ledger account
 					print "<td>";
 					/*if (empty($accounttoshow) || $accounttoshow == 'NotDefined')
@@ -1223,10 +1223,10 @@ if (empty($action) || $action == 'view') {
 					else print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE);
 					*/
 					print "</td>";
-					print "<td>" . $reflabel . "</td>";
-					print '<td class="center">' . $val["type_payment"] . "</td>";
-					print '<td class="right nowraponall">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
-					print '<td class="right nowraponall">' . ($mt >= 0 ? price($mt) : '') . "</td>";
+					print "<td>".$reflabel."</td>";
+					print '<td class="center">'.$val["type_payment"]."</td>";
+					print '<td class="right nowraponall">'.($mt < 0 ? price(-$mt) : '')."</td>";
+					print '<td class="right nowraponall">'.($mt >= 0 ? price($mt) : '')."</td>";
 					print "</tr>";
 				}
 			}
@@ -1287,63 +1287,63 @@ function getSourceDocRef($val, $typerecord)
 	{
 		$sqlmid = 'SELECT payfac.fk_facture as id, f.ref as ref';
 		$sqlmid .= " FROM ".MAIN_DB_PREFIX."paiement_facture as payfac, ".MAIN_DB_PREFIX."facture as f";
-		$sqlmid .= " WHERE payfac.fk_facture = f.rowid AND payfac.fk_paiement=" . $val["paymentid"];
+		$sqlmid .= " WHERE payfac.fk_facture = f.rowid AND payfac.fk_paiement=".$val["paymentid"];
 		$ref = $langs->transnoentitiesnoconv("Invoice");
 	}
 	elseif ($typerecord == 'payment_supplier')
 	{
 		$sqlmid = 'SELECT payfac.fk_facturefourn as id, f.ref';
-		$sqlmid .= " FROM " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfac, ".MAIN_DB_PREFIX."facture_fourn as f";
-		$sqlmid .= " WHERE payfac.fk_facturefourn = f.rowid AND payfac.fk_paiementfourn=" . $val["paymentsupplierid"];
+		$sqlmid .= " FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn as payfac, ".MAIN_DB_PREFIX."facture_fourn as f";
+		$sqlmid .= " WHERE payfac.fk_facturefourn = f.rowid AND payfac.fk_paiementfourn=".$val["paymentsupplierid"];
 		$ref = $langs->transnoentitiesnoconv("SupplierInvoice");
 	}
 	elseif ($typerecord == 'payment_expensereport')
 	{
 		$sqlmid = 'SELECT e.rowid as id, e.ref';
-		$sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_expensereport as pe, " . MAIN_DB_PREFIX . "expensereport as e";
-		$sqlmid .= " WHERE pe.rowid=" . $val["paymentexpensereport"]." AND pe.fk_expensereport = e.rowid";
+		$sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_expensereport as pe, ".MAIN_DB_PREFIX."expensereport as e";
+		$sqlmid .= " WHERE pe.rowid=".$val["paymentexpensereport"]." AND pe.fk_expensereport = e.rowid";
 		$ref = $langs->transnoentitiesnoconv("ExpenseReport");
 	}
 	elseif ($typerecord == 'payment_salary')
 	{
 		$sqlmid = 'SELECT s.rowid as ref';
-		$sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_salary as s";
-		$sqlmid .= " WHERE s.rowid=" . $val["paymentsalid"];
+		$sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_salary as s";
+		$sqlmid .= " WHERE s.rowid=".$val["paymentsalid"];
 		$ref = $langs->transnoentitiesnoconv("SalaryPayment");
 	}
 	elseif ($typerecord == 'sc')
 	{
 		$sqlmid = 'SELECT sc.rowid as ref';
-		$sqlmid .= " FROM " . MAIN_DB_PREFIX . "paiementcharge as sc";
-		$sqlmid .= " WHERE sc.rowid=" . $val["paymentscid"];
+		$sqlmid .= " FROM ".MAIN_DB_PREFIX."paiementcharge as sc";
+		$sqlmid .= " WHERE sc.rowid=".$val["paymentscid"];
 		$ref = $langs->transnoentitiesnoconv("SocialContribution");
 	}
 	elseif ($typerecord == 'payment_vat')
 	{
 		$sqlmid = 'SELECT v.rowid as ref';
-		$sqlmid .= " FROM " . MAIN_DB_PREFIX . "tva as v";
-		$sqlmid .= " WHERE v.rowid=" . $val["paymentvatid"];
+		$sqlmid .= " FROM ".MAIN_DB_PREFIX."tva as v";
+		$sqlmid .= " WHERE v.rowid=".$val["paymentvatid"];
 		$ref = $langs->transnoentitiesnoconv("PaymentVat");
 	}
 	elseif ($typerecord == 'payment_donation')
 	{
 		$sqlmid = 'SELECT payd.fk_donation as ref';
-		$sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_donation as payd";
-		$sqlmid .= " WHERE payd.fk_donation=" . $val["paymentdonationid"];
+		$sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_donation as payd";
+		$sqlmid .= " WHERE payd.fk_donation=".$val["paymentdonationid"];
 		$ref = $langs->transnoentitiesnoconv("Donation");
 	}
 	elseif ($typerecord == 'payment_loan')
 	{
 		$sqlmid = 'SELECT l.rowid as ref';
-		$sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_loan as l";
-		$sqlmid .= " WHERE l.rowid=" . $val["paymentloanid"];
+		$sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_loan as l";
+		$sqlmid .= " WHERE l.rowid=".$val["paymentloanid"];
 		$ref = $langs->transnoentitiesnoconv("LoanPayment");
 	}
 	elseif ($typerecord == 'payment_various')
 	{
 		$sqlmid = 'SELECT v.rowid as ref';
-		$sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_various as v";
-		$sqlmid .= " WHERE v.rowid=" . $val["paymentvariousid"];
+		$sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_various as v";
+		$sqlmid .= " WHERE v.rowid=".$val["paymentvariousid"];
 		$ref = $langs->transnoentitiesnoconv("VariousPayment");
 	}
 	// Add warning
@@ -1354,18 +1354,18 @@ function getSourceDocRef($val, $typerecord)
 
 	if ($sqlmid)
 	{
-		dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG);
+		dol_syslog("accountancy/journal/bankjournal.php::sqlmid=".$sqlmid, LOG_DEBUG);
 		$resultmid = $db->query($sqlmid);
 		if ($resultmid)
 		{
 			while ($objmid = $db->fetch_object($resultmid))
 			{
-				$ref.=' '.$objmid->ref;
+				$ref .= ' '.$objmid->ref;
 			}
 		}
 		else dol_print_error($db);
 	}
 
-	$ref = dol_trunc($langs->transnoentitiesnoconv("BankId").' '.$val['fk_bank'].' - '.$ref, 295);	// 295 + 3 dots (...) is < than max size of 300
+	$ref = dol_trunc($langs->transnoentitiesnoconv("BankId").' '.$val['fk_bank'].' - '.$ref, 295); // 295 + 3 dots (...) is < than max size of 300
 	return $ref;
 }

+ 24 - 24
htdocs/accountancy/journal/expensereportsjournal.php

@@ -321,7 +321,7 @@ if ($action == 'writebookkeeping') {
 						$accountingaccount->fetch($k, null, true);
 						$bookkeeping->label_compte = $accountingaccount->label;
 
-						$bookkeeping->label_operation = $langs->trans("VAT"). ' '.join(', ', $def_tva[$key][$k]).' %';
+						$bookkeeping->label_operation = $langs->trans("VAT").' '.join(', ', $def_tva[$key][$k]).' %';
 						$bookkeeping->montant = $mt;
 						$bookkeeping->sens = ($mt < 0) ? 'C' : 'D';
 						$bookkeeping->debit = ($mt > 0) ? $mt : 0;
@@ -448,36 +448,36 @@ if ($action == 'exportcsv') {		// ISO and not UTF8 !
 	        $accountingaccount = new AccountingAccount($db);
 	        $accountingaccount->fetch(null, $k, true);
 	        if ($mt) {
-	            print '"' . $date . '"' . $sep;
-	            print '"' . $val["ref"] . '"' . $sep;
-	            print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
-	            print '"' . dol_trunc($accountingaccount->label, 32) . '"' . $sep;
-	            print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
-	            print '"' . ($mt < 0 ? price(- $mt) : '') . '"';
+	            print '"'.$date.'"'.$sep;
+	            print '"'.$val["ref"].'"'.$sep;
+	            print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
+	            print '"'.dol_trunc($accountingaccount->label, 32).'"'.$sep;
+	            print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep;
+	            print '"'.($mt < 0 ? price(-$mt) : '').'"';
 	            print "\n";
 	        }
 	    }
 	    // VAT
 	    foreach ($tabtva[$key] as $k => $mt) {
 	        if ($mt) {
-	            print '"' . $date . '"' . $sep;
-	            print '"' . $val["ref"] . '"' . $sep;
-	            print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
-	            print '"' . dol_trunc($langs->trans("VAT")) . '"' . $sep;
-	            print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
-	            print '"' . ($mt < 0 ? price(- $mt) : '') . '"';
+	            print '"'.$date.'"'.$sep;
+	            print '"'.$val["ref"].'"'.$sep;
+	            print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
+	            print '"'.dol_trunc($langs->trans("VAT")).'"'.$sep;
+	            print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep;
+	            print '"'.($mt < 0 ? price(-$mt) : '').'"';
 	            print "\n";
 	        }
 	    }
 
 	    // Third party
 	    foreach ($tabttc[$key] as $k => $mt) {
-	        print '"' . $date . '"' . $sep;
-	        print '"' . $val["ref"] . '"' . $sep;
-	        print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
-	        print '"' . dol_trunc($userstatic->name) . '"' . $sep;
-	        print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
-	        print '"' . ($mt >= 0 ? price($mt) : '') . '"';
+	        print '"'.$date.'"'.$sep;
+	        print '"'.$val["ref"].'"'.$sep;
+	        print '"'.length_accounta(html_entity_decode($k)).'"'.$sep;
+	        print '"'.dol_trunc($userstatic->name).'"'.$sep;
+	        print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep;
+	        print '"'.($mt >= 0 ? price($mt) : '').'"';
 	    }
 	    print "\n";
 	}
@@ -641,8 +641,8 @@ if (empty($action) || $action == 'view') {
 				if ($mt) {
 					print '<tr class="oddeven">';
 					print "<!-- VAT -->";
-					print "<td>" . $date . "</td>";
-					print "<td>" . $expensereportstatic->getNomUrl(1) . "</td>";
+					print "<td>".$date."</td>";
+					print "<td>".$expensereportstatic->getNomUrl(1)."</td>";
 					// Account
 					print "<td>";
 					$accountoshow = length_accountg($k);
@@ -655,10 +655,10 @@ if (empty($action) || $action == 'view') {
 					// Subledger account
 					print "<td>";
 					print '</td>';
-					print "<td>" . $userstatic->getNomUrl(0, 'user', 16) . ' - ' . $langs->trans("VAT"). ' '.join(', ', $def_tva[$key][$k]).' %'.($numtax?' - Localtax '.$numtax:'');
+					print "<td>".$userstatic->getNomUrl(0, 'user', 16).' - '.$langs->trans("VAT").' '.join(', ', $def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : '');
 					print "</td>";
-					print '<td class="right nowraponall">' . ($mt >= 0 ? price($mt) : '') . "</td>";
-					print '<td class="right nowraponall">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
+					print '<td class="right nowraponall">'.($mt >= 0 ? price($mt) : '')."</td>";
+					print '<td class="right nowraponall">'.($mt < 0 ? price(-$mt) : '')."</td>";
 					print "</tr>";
 				}
 			}

+ 29 - 29
htdocs/accountancy/journal/purchasesjournal.php

@@ -301,7 +301,7 @@ if ($action == 'writebookkeeping') {
 				$bookkeeping->date_creation = $now;
 				$bookkeeping->doc_type = 'supplier_invoice';
 				$bookkeeping->fk_doc = $key;
-				$bookkeeping->fk_docdet = 0;    // Useless, can be several lines that are source of this record to add
+				$bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add
 				$bookkeeping->thirdparty_code = $companystatic->code_fournisseur;
 				$bookkeeping->subledger_account = $tabcompany[$key]['code_compta_fournisseur'];
 				$bookkeeping->subledger_label = $tabcompany[$key]['name'];
@@ -310,7 +310,7 @@ if ($action == 'writebookkeeping') {
 				$accountingaccount->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER, true);
 				$bookkeeping->label_compte = $accountingaccount->label;
 
-				$bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref_supplier . ' - ' . $langs->trans("SubledgerAccount");
+				$bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref_supplier.' - '.$langs->trans("SubledgerAccount");
 				$bookkeeping->montant = $mt;
 				$bookkeeping->sens = ($mt >= 0) ? 'C' : 'D';
 				$bookkeeping->debit = ($mt <= 0) ? -$mt : 0;
@@ -329,14 +329,14 @@ if ($action == 'writebookkeeping') {
 					{
 						$error++;
 						$errorforline++;
-						$errorforinvoice[$key]='alreadyjournalized';
+						$errorforinvoice[$key] = 'alreadyjournalized';
 						//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
 					}
 					else
 					{
 						$error++;
 						$errorforline++;
-						$errorforinvoice[$key]='other';
+						$errorforinvoice[$key] = 'other';
 						setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
 					}
 				}
@@ -344,7 +344,7 @@ if ($action == 'writebookkeeping') {
 		}
 
 		// Product / Service
-		if (! $errorforline)
+		if (!$errorforline)
 		{
 			foreach ($tabht[$key] as $k => $mt) {
 				// get compte id and label
@@ -356,13 +356,13 @@ if ($action == 'writebookkeeping') {
 					$bookkeeping->date_creation = $now;
 					$bookkeeping->doc_type = 'supplier_invoice';
 					$bookkeeping->fk_doc = $key;
-					$bookkeeping->fk_docdet = 0;	// Useless, can be several lines that are source of this record to add
+					$bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add
 					$bookkeeping->thirdparty_code = $companystatic->code_fournisseur;
 					$bookkeeping->subledger_account = '';
 					$bookkeeping->subledger_label = '';
 					$bookkeeping->numero_compte = $k;
 					$bookkeeping->label_compte = $accountingaccount->label;
-					$bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref_supplier . ' - ' . $accountingaccount->label;
+					$bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref_supplier.' - '.$accountingaccount->label;
 					$bookkeeping->montant = $mt;
 					$bookkeeping->sens = ($mt < 0) ? 'C' : 'D';
 					$bookkeeping->debit = ($mt > 0) ? $mt : 0;
@@ -381,14 +381,14 @@ if ($action == 'writebookkeeping') {
 						{
 							$error++;
 							$errorforline++;
-							$errorforinvoice[$key]='alreadyjournalized';
+							$errorforinvoice[$key] = 'alreadyjournalized';
 							//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
 						}
 						else
 						{
 							$error++;
 							$errorforline++;
-							$errorforinvoice[$key]='other';
+							$errorforinvoice[$key] = 'other';
 							setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
 						}
 					}
@@ -398,10 +398,10 @@ if ($action == 'writebookkeeping') {
 
 		// VAT
 		// var_dump($tabtva);
-		if (! $errorforline)
+		if (!$errorforline)
 		{
-			$listoftax=array(0, 1, 2);
-			foreach($listoftax as $numtax)
+			$listoftax = array(0, 1, 2);
+			foreach ($listoftax as $numtax)
 			{
 				$arrayofvat = $tabtva;
 				if ($numtax == 1) $arrayofvat = $tablocaltax1;
@@ -416,7 +416,7 @@ if ($action == 'writebookkeeping') {
 						$bookkeeping->date_creation = $now;
 						$bookkeeping->doc_type = 'supplier_invoice';
 						$bookkeeping->fk_doc = $key;
-						$bookkeeping->fk_docdet = 0;    // Useless, can be several lines that are source of this record to add
+						$bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add
 						$bookkeeping->thirdparty_code = $companystatic->code_fournisseur;
 						$bookkeeping->subledger_account = '';
 						$bookkeeping->subledger_label = '';
@@ -425,7 +425,7 @@ if ($action == 'writebookkeeping') {
 						$accountingaccount->fetch($k, null, true);
 						$bookkeeping->label_compte = $accountingaccount->label;
 
-						$bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref_supplier . ' - ' . $langs->trans("VAT").' '.join(', ', $def_tva[$key][$k]) .' %' . ($numtax?' - Localtax '.$numtax:'');
+						$bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref_supplier.' - '.$langs->trans("VAT").' '.join(', ', $def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : '');
 						$bookkeeping->montant = $mt;
 						$bookkeeping->sens = ($mt < 0) ? 'C' : 'D';
 						$bookkeeping->debit = ($mt > 0) ? $mt : 0;
@@ -444,14 +444,14 @@ if ($action == 'writebookkeeping') {
 							{
 								$error++;
 								$errorforline++;
-								$errorforinvoice[$key]='alreadyjournalized';
+								$errorforinvoice[$key] = 'alreadyjournalized';
 								//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
 							}
 							else
 							{
 								$error++;
 								$errorforline++;
-								$errorforinvoice[$key]='other';
+								$errorforinvoice[$key] = 'other';
 								setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
 							}
 						}
@@ -462,7 +462,7 @@ if ($action == 'writebookkeeping') {
 
 		// Counterpart of VAT for VAT NPR
 		// var_dump($tabother);
-		if (! $errorforline && is_array($tabother[$key]))
+		if (!$errorforline && is_array($tabother[$key]))
 		{
 			foreach ($tabother[$key] as $k => $mt) {
 				if ($mt) {
@@ -478,7 +478,7 @@ if ($action == 'writebookkeeping') {
 					$bookkeeping->subledger_account = '';
 					$bookkeeping->subledger_label = '';
 					$bookkeeping->numero_compte = $k;
-					$bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref_supplier . ' - ' . $langs->trans("VAT").' NPR';
+					$bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref_supplier.' - '.$langs->trans("VAT").' NPR';
 					$bookkeeping->montant = $mt;
 					$bookkeeping->sens = ($mt < 0) ? 'C' : 'D';
 					$bookkeeping->debit = ($mt > 0) ? $mt : 0;
@@ -513,7 +513,7 @@ if ($action == 'writebookkeeping') {
 		}
 
 		// Protection against a bug on lines before
-		if (! $errorforline && (price2num($totaldebit, 'MT') != price2num($totalcredit, 'MT')))
+		if (!$errorforline && (price2num($totaldebit, 'MT') != price2num($totalcredit, 'MT')))
 		{
 			$error++;
 			$errorforline++;
@@ -863,8 +863,8 @@ if (empty($action) || $action == 'view') {
 		foreach ($tabttc[$key] as $k => $mt) {
 			print '<tr class="oddeven">';
 			print "<!-- Thirdparty -->";
-			print "<td>" . $date . "</td>";
-			print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
+			print "<td>".$date."</td>";
+			print "<td>".$invoicestatic->getNomUrl(1)."</td>";
 			// Account
 			print "<td>";
 			$accountoshow = length_accounta($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER);
@@ -883,9 +883,9 @@ if (empty($action) || $action == 'view') {
 			}
 			else print $accountoshow;
 			print '</td>';
-			print "<td>" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->ref_supplier . ' - ' . $langs->trans("SubledgerAccount") . "</td>";
-			print '<td class="right nowraponall">'. ($mt < 0 ? price(- $mt) : '') . "</td>";
-			print '<td class="right nowraponall">' . ($mt >= 0 ? price($mt) : '') . "</td>";
+			print "<td>".$companystatic->getNomUrl(0, 'supplier', 16).' - '.$invoicestatic->ref_supplier.' - '.$langs->trans("SubledgerAccount")."</td>";
+			print '<td class="right nowraponall">'.($mt < 0 ? price(-$mt) : '')."</td>";
+			print '<td class="right nowraponall">'.($mt >= 0 ? price($mt) : '')."</td>";
 			print "</tr>";
 		}
 
@@ -896,8 +896,8 @@ if (empty($action) || $action == 'view') {
 
 			print '<tr class="oddeven">';
 			print "<!-- Product -->";
-			print "<td>" . $date . "</td>";
-			print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
+			print "<td>".$date."</td>";
+			print "<td>".$invoicestatic->getNomUrl(1)."</td>";
 			// Account
 			print "<td>";
 			$accountoshow = length_accountg($k);
@@ -912,9 +912,9 @@ if (empty($action) || $action == 'view') {
 			print '</td>';
 			$companystatic->id = $tabcompany[$key]['id'];
 			$companystatic->name = $tabcompany[$key]['name'];
-			print "<td>" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->ref_supplier . ' - ' . $accountingaccount->label . "</td>";
-			print '<td class="right nowraponall">' . ($mt >= 0 ? price($mt) : '') . "</td>";
-			print '<td class="right nowraponall">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
+			print "<td>".$companystatic->getNomUrl(0, 'supplier', 16).' - '.$invoicestatic->ref_supplier.' - '.$accountingaccount->label."</td>";
+			print '<td class="right nowraponall">'.($mt >= 0 ? price($mt) : '')."</td>";
+			print '<td class="right nowraponall">'.($mt < 0 ? price(-$mt) : '')."</td>";
 			print "</tr>";
 		}
 

+ 34 - 34
htdocs/accountancy/journal/sellsjournal.php

@@ -99,31 +99,31 @@ $sql = "SELECT f.rowid, f.ref, f.type, f.datef as df, f.ref_client, f.date_lim_r
 $sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.total_tva, fd.total_localtax1, fd.total_localtax2, fd.tva_tx, fd.total_ttc, fd.situation_percent, fd.vat_src_code,";
 $sql .= " s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,";
 $sql .= " p.rowid as pid, p.ref as pref, p.accountancy_code_sell, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte";
-$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
-$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = fd.fk_product";
-$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
-$sql .= " JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture";
-$sql .= " JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc";
+$sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd";
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = fd.fk_product";
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
+$sql .= " JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture";
+$sql .= " JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc";
 $sql .= " WHERE fd.fk_code_ventilation > 0";
-$sql .= " AND f.entity IN (".getEntity('invoice', 0).')';	// We don't share object for accountancy, we use source object sharing
+$sql .= " AND f.entity IN (".getEntity('invoice', 0).')'; // We don't share object for accountancy, we use source object sharing
 $sql .= " AND f.fk_statut > 0";
-if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {	// Non common setup
-	$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)) {	// Non common setup
+	$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 fd.product_type IN (0,1)";
 if ($date_start && $date_end)
-	$sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'";
+	$sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
 // Already in bookkeeping or not
 if ($in_bookkeeping == 'already')
 {
-	$sql .= " AND f.rowid IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')";
+	$sql .= " AND f.rowid IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')";
 	//	$sql .= " AND fd.rowid IN (SELECT fk_docdet FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')";		// Useless, we save one line for all products with same account
 }
 if ($in_bookkeeping == 'notyet')
 {
-	$sql .= " AND f.rowid NOT IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')";
+	$sql .= " AND f.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')";
     // $sql .= " AND fd.rowid NOT IN (SELECT fk_docdet FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')";		// Useless, we save one line for all products with same account
 }
 $sql .= " ORDER BY f.datef";
@@ -312,7 +312,7 @@ if ($action == 'writebookkeeping') {
 				$bookkeeping->date_creation = $now;
 				$bookkeeping->doc_type = 'customer_invoice';
 				$bookkeeping->fk_doc = $key;
-				$bookkeeping->fk_docdet = 0;	// Useless, can be several lines that are source of this record to add
+				$bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add
 				$bookkeeping->thirdparty_code = $companystatic->code_client;
 				$bookkeeping->subledger_account = $tabcompany[$key]['code_compta'];
 				$bookkeeping->subledger_label = $tabcompany[$key]['name'];
@@ -321,7 +321,7 @@ if ($action == 'writebookkeeping') {
 				$accountingaccount->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER, true);
 				$bookkeeping->label_compte = $accountingaccount->label;
 
-				$bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("SubledgerAccount");
+				$bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref.' - '.$langs->trans("SubledgerAccount");
 				$bookkeeping->montant = $mt;
 				$bookkeeping->sens = ($mt >= 0) ? 'D' : 'C';
 				$bookkeeping->debit = ($mt >= 0) ? $mt : 0;
@@ -340,14 +340,14 @@ if ($action == 'writebookkeeping') {
 					{
 						$error++;
 						$errorforline++;
-						$errorforinvoice[$key]='alreadyjournalized';
+						$errorforinvoice[$key] = 'alreadyjournalized';
 						//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
 					}
 					else
 					{
 						$error++;
 						$errorforline++;
-						$errorforinvoice[$key]='other';
+						$errorforinvoice[$key] = 'other';
 						setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
 					}
 				}
@@ -355,7 +355,7 @@ if ($action == 'writebookkeeping') {
 		}
 
 		// Product / Service
-		if (! $errorforline)
+		if (!$errorforline)
 		{
 			foreach ($tabht[$key] as $k => $mt) {
 				// get compte id and label
@@ -373,7 +373,7 @@ if ($action == 'writebookkeeping') {
 					$bookkeeping->subledger_label = '';
 					$bookkeeping->numero_compte = $k;
 					$bookkeeping->label_compte = $accountingaccount->label;
-					$bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $accountingaccount->label;
+					$bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref.' - '.$accountingaccount->label;
 					$bookkeeping->montant = $mt;
 					$bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
 					$bookkeeping->debit = ($mt < 0) ? -$mt : 0;
@@ -408,10 +408,10 @@ if ($action == 'writebookkeeping') {
 		}
 
 		// VAT
-		if (! $errorforline)
+		if (!$errorforline)
 		{
-			$listoftax=array(0, 1, 2);
-			foreach($listoftax as $numtax)
+			$listoftax = array(0, 1, 2);
+			foreach ($listoftax as $numtax)
 			{
 				$arrayofvat = $tabtva;
 				if ($numtax == 1) $arrayofvat = $tablocaltax1;
@@ -426,7 +426,7 @@ if ($action == 'writebookkeeping') {
 						$bookkeeping->date_creation = $now;
 						$bookkeeping->doc_type = 'customer_invoice';
 						$bookkeeping->fk_doc = $key;
-						$bookkeeping->fk_docdet = 0;	// Useless, can be several lines that are source of this record to add
+						$bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add
 						$bookkeeping->thirdparty_code = $companystatic->code_client;
 						$bookkeeping->subledger_account = '';
 						$bookkeeping->subledger_label = '';
@@ -435,7 +435,7 @@ if ($action == 'writebookkeeping') {
 						$accountingaccount->fetch($k, null, true);
 						$bookkeeping->label_compte = $accountingaccount->label;
 
-						$bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT").' '.join(', ', $def_tva[$key][$k]) .' %' . ($numtax?' - Localtax '.$numtax:'');
+						$bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref.' - '.$langs->trans("VAT").' '.join(', ', $def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : '');
 						$bookkeeping->montant = $mt;
 						$bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
 						$bookkeeping->debit = ($mt < 0) ? -$mt : 0;
@@ -471,7 +471,7 @@ if ($action == 'writebookkeeping') {
 		}
 
 		// Protection against a bug on lines before
-		if (! $errorforline && (price2num($totaldebit, 'MT') != price2num($totalcredit, 'MT')))
+		if (!$errorforline && (price2num($totaldebit, 'MT') != price2num($totalcredit, 'MT')))
 		{
 			$error++;
 			$errorforline++;
@@ -799,8 +799,8 @@ if (empty($action) || $action == 'view') {
 		{
 			print '<tr class="oddeven">';
 			print "<!-- Thirdparty -->";
-			print "<td>" . $date . "</td>";
-			print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
+			print "<td>".$date."</td>";
+			print "<td>".$invoicestatic->getNomUrl(1)."</td>";
 			// Account
 			print "<td>";
 			$accountoshow = length_accounta($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER);
@@ -819,9 +819,9 @@ if (empty($action) || $action == 'view') {
 			}
 			else print $accountoshow;
 			print '</td>';
-			print "<td>" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("SubledgerAccount") . "</td>";
-			print '<td class="right nowraponall">' . ($mt >= 0 ? price($mt) : '') . "</td>";
-			print '<td class="right nowraponall">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
+			print "<td>".$companystatic->getNomUrl(0, 'customer', 16).' - '.$invoicestatic->ref.' - '.$langs->trans("SubledgerAccount")."</td>";
+			print '<td class="right nowraponall">'.($mt >= 0 ? price($mt) : '')."</td>";
+			print '<td class="right nowraponall">'.($mt < 0 ? price(-$mt) : '')."</td>";
 			print "</tr>";
 		}
 
@@ -833,8 +833,8 @@ if (empty($action) || $action == 'view') {
 
 			print '<tr class="oddeven">';
 			print "<!-- Product -->";
-			print "<td>" . $date . "</td>";
-			print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
+			print "<td>".$date."</td>";
+			print "<td>".$invoicestatic->getNomUrl(1)."</td>";
 			// Account
 			print "<td>";
 			$accountoshow = length_accountg($k);
@@ -849,9 +849,9 @@ if (empty($action) || $action == 'view') {
 			print '</td>';
 			$companystatic->id = $tabcompany[$key]['id'];
 			$companystatic->name = $tabcompany[$key]['name'];
-			print "<td>" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $accountingaccount->label . "</td>";
-			print '<td class="right nowraponall">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
-			print '<td class="right nowraponall">' . ($mt >= 0 ? price($mt) : '') . "</td>";
+			print "<td>".$companystatic->getNomUrl(0, 'customer', 16).' - '.$invoicestatic->ref.' - '.$accountingaccount->label."</td>";
+			print '<td class="right nowraponall">'.($mt < 0 ? price(-$mt) : '')."</td>";
+			print '<td class="right nowraponall">'.($mt >= 0 ? price($mt) : '')."</td>";
 			print "</tr>";
 		}
 

+ 47 - 47
htdocs/adherents/admin/adherent.php

@@ -34,12 +34,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
 
 // Load translation files required by the page
-$langs->loadLangs(array("admin","members"));
+$langs->loadLangs(array("admin", "members"));
 
-if (! $user->admin) accessforbidden();
+if (!$user->admin) accessforbidden();
 
 
-$type=array('yesno','texte','chaine');
+$type = array('yesno', 'texte', 'chaine');
 
 $action = GETPOST('action', 'alpha');
 
@@ -52,19 +52,19 @@ $action = GETPOST('action', 'alpha');
 if ($action == 'updateall')
 {
     $db->begin();
-    $res1=$res2=$res3=$res4=$res5=$res6=0;
-    $res1=dolibarr_set_const($db, 'ADHERENT_LOGIN_NOT_REQUIRED', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha')?0:1, 'chaine', 0, '', $conf->entity);
-    $res2=dolibarr_set_const($db, 'ADHERENT_MAIL_REQUIRED', GETPOST('ADHERENT_MAIL_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity);
-    $res3=dolibarr_set_const($db, 'ADHERENT_DEFAULT_SENDINFOBYMAIL', GETPOST('ADHERENT_DEFAULT_SENDINFOBYMAIL', 'alpha'), 'chaine', 0, '', $conf->entity);
-    $res4=dolibarr_set_const($db, 'ADHERENT_BANK_USE', GETPOST('ADHERENT_BANK_USE', 'alpha'), 'chaine', 0, '', $conf->entity);
+    $res1 = $res2 = $res3 = $res4 = $res5 = $res6 = 0;
+    $res1 = dolibarr_set_const($db, 'ADHERENT_LOGIN_NOT_REQUIRED', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha') ? 0 : 1, 'chaine', 0, '', $conf->entity);
+    $res2 = dolibarr_set_const($db, 'ADHERENT_MAIL_REQUIRED', GETPOST('ADHERENT_MAIL_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity);
+    $res3 = dolibarr_set_const($db, 'ADHERENT_DEFAULT_SENDINFOBYMAIL', GETPOST('ADHERENT_DEFAULT_SENDINFOBYMAIL', 'alpha'), 'chaine', 0, '', $conf->entity);
+    $res4 = dolibarr_set_const($db, 'ADHERENT_BANK_USE', GETPOST('ADHERENT_BANK_USE', 'alpha'), 'chaine', 0, '', $conf->entity);
     // Use vat for invoice creation
     if ($conf->facture->enabled)
     {
-        $res4=dolibarr_set_const($db, 'ADHERENT_VAT_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_VAT_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity);
-        $res5=dolibarr_set_const($db, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity);
-        if (! empty($conf->product->enabled) || ! empty($conf->service->enabled))
+        $res4 = dolibarr_set_const($db, 'ADHERENT_VAT_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_VAT_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity);
+        $res5 = dolibarr_set_const($db, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity);
+        if (!empty($conf->product->enabled) || !empty($conf->service->enabled))
         {
-            $res6=dolibarr_set_const($db, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity);
+            $res6 = dolibarr_set_const($db, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity);
         }
     }
     if ($res1 < 0 || $res2 < 0 || $res3 < 0 || $res4 < 0 || $res5 < 0 || $res6 < 0)
@@ -82,23 +82,23 @@ if ($action == 'updateall')
 // Action to update or add a constant
 if ($action == 'update' || $action == 'add')
 {
-	$constname=GETPOST('constname', 'alpha');
-	$constvalue=(GETPOST('constvalue_'.$constname) ? GETPOST('constvalue_'.$constname) : GETPOST('constvalue'));
+	$constname = GETPOST('constname', 'alpha');
+	$constvalue = (GETPOST('constvalue_'.$constname) ? GETPOST('constvalue_'.$constname) : GETPOST('constvalue'));
 
-	if (($constname=='ADHERENT_CARD_TYPE' || $constname=='ADHERENT_ETIQUETTE_TYPE' || $constname=='ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS') && $constvalue == -1) $constvalue='';
-	if ($constname=='ADHERENT_LOGIN_NOT_REQUIRED') // Invert choice
+	if (($constname == 'ADHERENT_CARD_TYPE' || $constname == 'ADHERENT_ETIQUETTE_TYPE' || $constname == 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS') && $constvalue == -1) $constvalue = '';
+	if ($constname == 'ADHERENT_LOGIN_NOT_REQUIRED') // Invert choice
 	{
-		if ($constvalue) $constvalue=0;
-		else $constvalue=1;
+		if ($constvalue) $constvalue = 0;
+		else $constvalue = 1;
 	}
 
-	$consttype=GETPOST('consttype', 'alpha');
-	$constnote=GETPOST('constnote');
-	$res=dolibarr_set_const($db, $constname, $constvalue, $type[$consttype], 0, $constnote, $conf->entity);
+	$consttype = GETPOST('consttype', 'alpha');
+	$constnote = GETPOST('constnote');
+	$res = dolibarr_set_const($db, $constname, $constvalue, $type[$consttype], 0, $constnote, $conf->entity);
 
-	if (! $res > 0) $error++;
+	if (!$res > 0) $error++;
 
-	if (! $error)
+	if (!$error)
 	{
 		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
 	}
@@ -111,7 +111,7 @@ if ($action == 'update' || $action == 'add')
 // Action to enable of a submodule of the adherent module
 if ($action == 'set')
 {
-    $result=dolibarr_set_const($db, GETPOST('name', 'alpha'), GETPOST('value'), '', 0, '', $conf->entity);
+    $result = dolibarr_set_const($db, GETPOST('name', 'alpha'), GETPOST('value'), '', 0, '', $conf->entity);
     if ($result < 0)
     {
         print $db->error();
@@ -121,7 +121,7 @@ if ($action == 'set')
 // Action to disable a submodule of the adherent module
 if ($action == 'unset')
 {
-    $result=dolibarr_del_const($db, GETPOST('name', 'alpha'), $conf->entity);
+    $result = dolibarr_del_const($db, GETPOST('name', 'alpha'), $conf->entity);
     if ($result < 0)
     {
         print $db->error();
@@ -136,12 +136,12 @@ if ($action == 'unset')
 
 $form = new Form($db);
 
-$help_url='EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros';
+$help_url = 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros';
 
 llxHeader('', $langs->trans("MembersSetup"), $help_url);
 
 
-$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("MembersSetup"), $linkback, 'title_setup');
 
 
@@ -162,25 +162,25 @@ print "</tr>\n";
 
 // Login/Pass required for members
 print '<tr class="oddeven"><td>'.$langs->trans("AdherentLoginRequired").'</td><td>';
-print $form->selectyesno('ADHERENT_LOGIN_NOT_REQUIRED', (! empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)?0:1), 1);
+print $form->selectyesno('ADHERENT_LOGIN_NOT_REQUIRED', (!empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED) ? 0 : 1), 1);
 print "</td></tr>\n";
 
 // Mail required for members
 print '<tr class="oddeven"><td>'.$langs->trans("AdherentMailRequired").'</td><td>';
-print $form->selectyesno('ADHERENT_MAIL_REQUIRED', (! empty($conf->global->ADHERENT_MAIL_REQUIRED)?$conf->global->ADHERENT_MAIL_REQUIRED:0), 1);
+print $form->selectyesno('ADHERENT_MAIL_REQUIRED', (!empty($conf->global->ADHERENT_MAIL_REQUIRED) ? $conf->global->ADHERENT_MAIL_REQUIRED : 0), 1);
 print "</td></tr>\n";
 
 // Send mail information is on by default
 print '<tr class="oddeven"><td>'.$langs->trans("MemberSendInformationByMailByDefault").'</td><td>';
-print $form->selectyesno('ADHERENT_DEFAULT_SENDINFOBYMAIL', (! empty($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL)?$conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL:0), 1);
+print $form->selectyesno('ADHERENT_DEFAULT_SENDINFOBYMAIL', (!empty($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL) ? $conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL : 0), 1);
 print "</td></tr>\n";
 
 // Insert subscription into bank account
 print '<tr class="oddeven"><td>'.$langs->trans("MoreActionsOnSubscription").'</td>';
-$arraychoices=array('0'=>$langs->trans("None"));
-if (! empty($conf->banque->enabled)) $arraychoices['bankdirect']=$langs->trans("MoreActionBankDirect");
-if (! empty($conf->banque->enabled) && ! empty($conf->societe->enabled) && ! empty($conf->facture->enabled)) $arraychoices['invoiceonly']=$langs->trans("MoreActionInvoiceOnly");
-if (! empty($conf->banque->enabled) && ! empty($conf->societe->enabled) && ! empty($conf->facture->enabled)) $arraychoices['bankviainvoice']=$langs->trans("MoreActionBankViaInvoice");
+$arraychoices = array('0'=>$langs->trans("None"));
+if (!empty($conf->banque->enabled)) $arraychoices['bankdirect'] = $langs->trans("MoreActionBankDirect");
+if (!empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) $arraychoices['invoiceonly'] = $langs->trans("MoreActionInvoiceOnly");
+if (!empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) $arraychoices['bankviainvoice'] = $langs->trans("MoreActionBankViaInvoice");
 print '<td>';
 print $form->selectarray('ADHERENT_BANK_USE', $arraychoices, $conf->global->ADHERENT_BANK_USE, 0);
 if ($conf->global->ADHERENT_BANK_USE == 'bankdirect' || $conf->global->ADHERENT_BANK_USE == 'bankviainvoice')
@@ -194,10 +194,10 @@ print "</tr>\n";
 if ($conf->facture->enabled)
 {
 	print '<tr class="oddeven"><td>'.$langs->trans("VATToUseForSubscriptions").'</td>';
-	if (! empty($conf->banque->enabled))
+	if (!empty($conf->banque->enabled))
 	{
 		print '<td>';
-		print $form->selectarray('ADHERENT_VAT_FOR_SUBSCRIPTIONS', array('0'=>$langs->trans("NoVatOnSubscription"),'defaultforfoundationcountry'=>$langs->trans("Default")), (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS)?'0':$conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS), 0);
+		print $form->selectarray('ADHERENT_VAT_FOR_SUBSCRIPTIONS', array('0'=>$langs->trans("NoVatOnSubscription"), 'defaultforfoundationcountry'=>$langs->trans("Default")), (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) ? '0' : $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS), 0);
 		print '</td>';
 	}
 	else
@@ -208,7 +208,7 @@ if ($conf->facture->enabled)
 	}
 	print "</tr>\n";
 
-	if (! empty($conf->product->enabled) || ! empty($conf->service->enabled))
+	if (!empty($conf->product->enabled) || !empty($conf->service->enabled))
 	{
 		print '<tr class="oddeven"><td>'.$langs->trans("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS").'</td>';
 		print '<td>';
@@ -232,7 +232,7 @@ print '<br>';
 /*
  * Edit info of model document
  */
-$constantes=array(
+$constantes = array(
 		'ADHERENT_CARD_TYPE',
 //		'ADHERENT_CARD_BACKGROUND',
 		'ADHERENT_CARD_HEADER_TEXT',
@@ -243,10 +243,10 @@ $constantes=array(
 
 print load_fiche_titre($langs->trans("MembersCards"), '', '');
 
-$helptext='*'.$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
-$helptext.='__DOL_MAIN_URL_ROOT__, __ID__, __FIRSTNAME__, __LASTNAME__, __FULLNAME__, __LOGIN__, __PASSWORD__, ';
-$helptext.='__COMPANY__, __ADDRESS__, __ZIP__, __TOWN__, __COUNTRY__, __EMAIL__, __BIRTH__, __PHOTO__, __TYPE__, ';
-$helptext.='__YEAR__, __MONTH__, __DAY__';
+$helptext = '*'.$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
+$helptext .= '__DOL_MAIN_URL_ROOT__, __ID__, __FIRSTNAME__, __LASTNAME__, __FULLNAME__, __LOGIN__, __PASSWORD__, ';
+$helptext .= '__COMPANY__, __ADDRESS__, __ZIP__, __TOWN__, __COUNTRY__, __EMAIL__, __BIRTH__, __PHOTO__, __TYPE__, ';
+$helptext .= '__YEAR__, __MONTH__, __DAY__';
 
 form_constantes($constantes, 0, $helptext);
 
@@ -256,14 +256,14 @@ print '<br>';
 /*
  * Edit info of model document
  */
-$constantes=array('ADHERENT_ETIQUETTE_TYPE','ADHERENT_ETIQUETTE_TEXT');
+$constantes = array('ADHERENT_ETIQUETTE_TYPE', 'ADHERENT_ETIQUETTE_TEXT');
 
 print load_fiche_titre($langs->trans("MembersTickets"), '', '');
 
-$helptext='*'.$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
-$helptext.='__DOL_MAIN_URL_ROOT__, __ID__, __FIRSTNAME__, __LASTNAME__, __FULLNAME__, __LOGIN__, __PASSWORD__, ';
-$helptext.='__COMPANY__, __ADDRESS__, __ZIP__, __TOWN__, __COUNTRY__, __EMAIL__, __BIRTH__, __PHOTO__, __TYPE__, ';
-$helptext.='__YEAR__, __MONTH__, __DAY__';
+$helptext = '*'.$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
+$helptext .= '__DOL_MAIN_URL_ROOT__, __ID__, __FIRSTNAME__, __LASTNAME__, __FULLNAME__, __LOGIN__, __PASSWORD__, ';
+$helptext .= '__COMPANY__, __ADDRESS__, __ZIP__, __TOWN__, __COUNTRY__, __EMAIL__, __BIRTH__, __PHOTO__, __TYPE__, ';
+$helptext .= '__YEAR__, __MONTH__, __DAY__';
 
 form_constantes($constantes, 0, $helptext);
 

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

@@ -34,25 +34,25 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
 
 // Load translation files required by the page
-$langs->loadLangs(array("admin","members"));
+$langs->loadLangs(array("admin", "members"));
 
-if (! $user->admin) accessforbidden();
+if (!$user->admin) accessforbidden();
 
 
-$oldtypetonewone=array('texte'=>'text','chaine'=>'string');	// old type to new ones
+$oldtypetonewone = array('texte'=>'text', 'chaine'=>'string'); // old type to new ones
 
 $action = GETPOST('action', 'alpha');
 
 $error = 0;
 
 // Editing global variables not related to a specific theme
-$constantes=array(
+$constantes = array(
     'MEMBER_REMINDER_EMAIL'=>array('type'=>'yesno', 'label'=>$langs->trans('MEMBER_REMINDER_EMAIL', $langs->transnoentities("Module2300Name"))),
     'ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION' =>'emailtemplate:member',
-    'ADHERENT_EMAIL_TEMPLATE_AUTOREGISTER'		=>'emailtemplate:member',		/* old was ADHERENT_AUTOREGISTER_MAIL */
-    'ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION'	=>'emailtemplate:member',		/* old was ADHERENT_MAIL_VALID */
-    'ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION'		=>'emailtemplate:member',		/* old was ADHERENT_MAIL_COTIS */
-    'ADHERENT_EMAIL_TEMPLATE_CANCELATION'		=>'emailtemplate:member',		/* old was ADHERENT_MAIL_RESIL */
+    'ADHERENT_EMAIL_TEMPLATE_AUTOREGISTER'		=>'emailtemplate:member', /* old was ADHERENT_AUTOREGISTER_MAIL */
+    'ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION'	=>'emailtemplate:member', /* old was ADHERENT_MAIL_VALID */
+    'ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION'		=>'emailtemplate:member', /* old was ADHERENT_MAIL_COTIS */
+    'ADHERENT_EMAIL_TEMPLATE_CANCELATION'		=>'emailtemplate:member', /* old was ADHERENT_MAIL_RESIL */
     'ADHERENT_MAIL_FROM'=>'string',
     'ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT'=>'string',
     'ADHERENT_AUTOREGISTER_NOTIF_MAIL'=>'html',
@@ -68,8 +68,8 @@ $constantes=array(
 if ($action == 'updateall')
 {
     $db->begin();
-    $res1=$res2=$res3=$res4=$res5=$res6=0;
-    $res1=dolibarr_set_const($db, 'XXXX', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity);
+    $res1 = $res2 = $res3 = $res4 = $res5 = $res6 = 0;
+    $res1 = dolibarr_set_const($db, 'XXXX', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity);
     if ($res1 < 0 || $res2 < 0 || $res3 < 0 || $res4 < 0 || $res5 < 0 || $res6 < 0)
     {
         setEventMessages('ErrorFailedToSaveDate', null, 'errors');
@@ -86,19 +86,19 @@ if ($action == 'updateall')
 if ($action == 'update' || $action == 'add')
 {
 	$constlineid = GETPOST('rowid', 'int');
-	$constname=GETPOST('constname', 'alpha');
+	$constname = GETPOST('constname', 'alpha');
 
-	$constvalue=(GETPOSTISSET('constvalue_'.$constname) ? GETPOST('constvalue_'.$constname, 'alpha') : GETPOST('constvalue'));
-	$consttype=(GETPOSTISSET('consttype_'.$constname) ? GETPOST('consttype_'.$constname, 'alphanohtml') : GETPOST('consttype'));
-	$constnote=(GETPOSTISSET('constnote_'.$constname) ? GETPOST('constnote_'.$constname, 'none') : GETPOST('constnote'));
+	$constvalue = (GETPOSTISSET('constvalue_'.$constname) ? GETPOST('constvalue_'.$constname, 'alpha') : GETPOST('constvalue'));
+	$consttype = (GETPOSTISSET('consttype_'.$constname) ? GETPOST('consttype_'.$constname, 'alphanohtml') : GETPOST('consttype'));
+	$constnote = (GETPOSTISSET('constnote_'.$constname) ? GETPOST('constnote_'.$constname, 'none') : GETPOST('constnote'));
 
 	$typetouse = empty($oldtypetonewone[$consttype]) ? $consttype : $oldtypetonewone[$consttype];
 
-	$res=dolibarr_set_const($db, $constname, $constvalue, $typetouse, 0, $constnote, $conf->entity);
+	$res = dolibarr_set_const($db, $constname, $constvalue, $typetouse, 0, $constnote, $conf->entity);
 
-	if (! $res > 0) $error++;
+	if (!$res > 0) $error++;
 
-	if (! $error)
+	if (!$error)
 	{
 		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
 	}
@@ -111,7 +111,7 @@ if ($action == 'update' || $action == 'add')
 // Action to enable a submodule of the adherent module
 if ($action == 'set')
 {
-    $result=dolibarr_set_const($db, GETPOST('name', 'alpha'), GETPOST('value'), '', 0, '', $conf->entity);
+    $result = dolibarr_set_const($db, GETPOST('name', 'alpha'), GETPOST('value'), '', 0, '', $conf->entity);
     if ($result < 0)
     {
         print $db->error();
@@ -121,7 +121,7 @@ if ($action == 'set')
 // Action to disable a submodule of the adherent module
 if ($action == 'unset')
 {
-    $result=dolibarr_del_const($db, GETPOST('name', 'alpha'), $conf->entity);
+    $result = dolibarr_del_const($db, GETPOST('name', 'alpha'), $conf->entity);
     if ($result < 0)
     {
         print $db->error();
@@ -136,12 +136,12 @@ if ($action == 'unset')
 
 $form = new Form($db);
 
-$help_url='EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros';
+$help_url = 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros';
 
 llxHeader('', $langs->trans("MembersSetup"), $help_url);
 
 
-$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("MembersSetup"), $linkback, 'title_setup');
 
 
@@ -154,9 +154,9 @@ dol_fiche_head($head, 'emails', $langs->trans("Members"), -1, 'user');
 //print '<input type="hidden" name="token" value="'.newToken().'">';
 //print '<input type="hidden" name="action" value="updateall">';
 
-$helptext='*'.$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
-$helptext.='__DOL_MAIN_URL_ROOT__, __ID__, __FIRSTNAME__, __LASTNAME__, __FULLNAME__, __LOGIN__, __PASSWORD__, ';
-$helptext.='__COMPANY__, __ADDRESS__, __ZIP__, __TOWN__, __COUNTRY__, __EMAIL__, __BIRTH__, __PHOTO__, __TYPE__, ';
+$helptext = '*'.$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
+$helptext .= '__DOL_MAIN_URL_ROOT__, __ID__, __FIRSTNAME__, __LASTNAME__, __FULLNAME__, __LOGIN__, __PASSWORD__, ';
+$helptext .= '__COMPANY__, __ADDRESS__, __ZIP__, __TOWN__, __COUNTRY__, __EMAIL__, __BIRTH__, __PHOTO__, __TYPE__, ';
 //$helptext.='__YEAR__, __MONTH__, __DAY__';	// Not supported
 
 form_constantes($constantes, 0, $helptext);

+ 10 - 10
htdocs/adherents/admin/adherent_extrafields.php

@@ -29,19 +29,19 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
 require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
 
 // Load translation files required by the page
-$langs->loadLangs(array("admin","members"));
+$langs->loadLangs(array("admin", "members"));
 
 $extrafields = new ExtraFields($db);
 $form = new Form($db);
 
 // List of supported format
-$tmptype2label=ExtraFields::$type2label;
-$type2label=array('');
-foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
+$tmptype2label = ExtraFields::$type2label;
+$type2label = array('');
+foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val);
 
-$action=GETPOST('action', 'alpha');
-$attrname=GETPOST('attrname', 'alpha');
-$elementtype='adherent'; //Must be the $table_element of the class that manage extrafield
+$action = GETPOST('action', 'alpha');
+$attrname = GETPOST('attrname', 'alpha');
+$elementtype = 'adherent'; //Must be the $table_element of the class that manage extrafield
 
 if (!$user->admin) accessforbidden();
 
@@ -60,11 +60,11 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
 
 $textobject = $langs->transnoentitiesnoconv("Members");
 
-$help_url='EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros';
+$help_url = 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros';
 llxHeader('', $langs->trans("MembersSetup"), $help_url);
 
 
-$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("MembersSetup"), $linkback, 'title_setup');
 
 
@@ -105,7 +105,7 @@ if ($action == 'create')
 /* Edition of an optional field                                               */
 /*                                                                            */
 /* ************************************************************************** */
-if ($action == 'edit' && ! empty($attrname))
+if ($action == 'edit' && !empty($attrname))
 {
 	print '<div name="topofform"></div><br>';
 	print load_fiche_titre($langs->trans("FieldEdition", $attrname));

+ 11 - 11
htdocs/adherents/admin/adherent_type_extrafields.php

@@ -32,19 +32,19 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
 require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
 
 // Load translation files required by the page
-$langs->loadLangs(array("admin","members"));
+$langs->loadLangs(array("admin", "members"));
 
 $extrafields = new ExtraFields($db);
 $form = new Form($db);
 
 // List of supported format
-$tmptype2label=ExtraFields::$type2label;
-$type2label=array('');
-foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
+$tmptype2label = ExtraFields::$type2label;
+$type2label = array('');
+foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val);
 
-$action=GETPOST('action', 'alpha');
-$attrname=GETPOST('attrname', 'alpha');
-$elementtype='adherent_type'; //Must be the $table_element of the class that manage extrafield
+$action = GETPOST('action', 'alpha');
+$attrname = GETPOST('attrname', 'alpha');
+$elementtype = 'adherent_type'; //Must be the $table_element of the class that manage extrafield
 
 if (!$user->admin) accessforbidden();
 
@@ -61,13 +61,13 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
  * View
  */
 
-$textobject=$langs->transnoentitiesnoconv("MembersTypes");
+$textobject = $langs->transnoentitiesnoconv("MembersTypes");
 
-$help_url='EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros';
+$help_url = 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros';
 llxHeader('', $langs->trans("MembersSetup"), $help_url);
 
 
-$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("MembersSetup"), $linkback, 'title_setup');
 
 
@@ -108,7 +108,7 @@ if ($action == 'create')
 /* Edition of an optional field                                               */
 /*                                                                            */
 /* ************************************************************************** */
-if ($action == 'edit' && ! empty($attrname))
+if ($action == 'edit' && !empty($attrname))
 {
 	print "<br>";
 	print load_fiche_titre($langs->trans("FieldEdition", $attrname));

+ 10 - 10
htdocs/adherents/admin/website.php

@@ -178,34 +178,34 @@ if (!empty($conf->global->MEMBER_ENABLE_PUBLIC))
 	$listofval = array();
 	$listofval += $adht->liste_array();
 	$forcetype = $conf->global->MEMBER_NEWFORM_FORCETYPE ?: -1;
-	print $form->selectarray("MEMBER_NEWFORM_FORCETYPE", $listofval, $forcetype, count($listofval)>1?1:0);
+	print $form->selectarray("MEMBER_NEWFORM_FORCETYPE", $listofval, $forcetype, count($listofval) > 1 ? 1 : 0);
 	print "</td></tr>\n";
 
 	// Amount
 	print '<tr class="oddeven" id="tramount"><td>';
 	print $langs->trans("DefaultAmount");
 	print '</td><td class="right">';
-	print '<input type="text" id="MEMBER_NEWFORM_AMOUNT" name="MEMBER_NEWFORM_AMOUNT" size="5" value="'.(! empty($conf->global->MEMBER_NEWFORM_AMOUNT)?$conf->global->MEMBER_NEWFORM_AMOUNT:'').'">';
+	print '<input type="text" id="MEMBER_NEWFORM_AMOUNT" name="MEMBER_NEWFORM_AMOUNT" size="5" value="'.(!empty($conf->global->MEMBER_NEWFORM_AMOUNT) ? $conf->global->MEMBER_NEWFORM_AMOUNT : '').'">';
 	print "</td></tr>\n";
 
 	// Can edit
 	print '<tr class="oddeven" id="tredit"><td>';
 	print $langs->trans("CanEditAmount");
 	print '</td><td class="right">';
-	print $form->selectyesno("MEMBER_NEWFORM_EDITAMOUNT", (! empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)?$conf->global->MEMBER_NEWFORM_EDITAMOUNT:0), 1);
+	print $form->selectyesno("MEMBER_NEWFORM_EDITAMOUNT", (!empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT) ? $conf->global->MEMBER_NEWFORM_EDITAMOUNT : 0), 1);
 	print "</td></tr>\n";
 
 	// Jump to an online payment page
 	print '<tr class="oddeven" id="trpayment"><td>';
 	print $langs->trans("MEMBER_NEWFORM_PAYONLINE");
 	print '</td><td class="right">';
-	$listofval=array();
-	$listofval['-1']=$langs->trans('No');
-	$listofval['all']=$langs->trans('Yes').' ('.$langs->trans("VisitorCanChooseItsPaymentMode").')';
-	if (! empty($conf->paybox->enabled)) $listofval['paybox']='Paybox';
-	if (! empty($conf->paypal->enabled)) $listofval['paypal']='PayPal';
-	if (! empty($conf->stripe->enabled)) $listofval['stripe']='Stripe';
-	print $form->selectarray("MEMBER_NEWFORM_PAYONLINE", $listofval, (! empty($conf->global->MEMBER_NEWFORM_PAYONLINE)?$conf->global->MEMBER_NEWFORM_PAYONLINE:''), 0);
+	$listofval = array();
+	$listofval['-1'] = $langs->trans('No');
+	$listofval['all'] = $langs->trans('Yes').' ('.$langs->trans("VisitorCanChooseItsPaymentMode").')';
+	if (!empty($conf->paybox->enabled)) $listofval['paybox'] = 'Paybox';
+	if (!empty($conf->paypal->enabled)) $listofval['paypal'] = 'PayPal';
+	if (!empty($conf->stripe->enabled)) $listofval['stripe'] = 'Stripe';
+	print $form->selectarray("MEMBER_NEWFORM_PAYONLINE", $listofval, (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE) ? $conf->global->MEMBER_NEWFORM_PAYONLINE : ''), 0);
 	print "</td></tr>\n";
 
 	print '</table>';

+ 8 - 8
htdocs/adherents/agenda.php

@@ -149,24 +149,24 @@ if ($object->id > 0)
 
 
 	$newcardbutton = '';
-    if (! empty($conf->agenda->enabled))
+    if (!empty($conf->agenda->enabled))
     {
-        $newcardbutton.= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&backtopage=1&origin=member&originid='.$id);
+        $newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&backtopage=1&origin=member&originid='.$id);
     }
 
-    if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) ))
+    if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read)))
     {
     	print '<br>';
 
-    	$param='&id='.$id;
-    	if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
-    	if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
+    	$param = '&id='.$id;
+    	if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage;
+    	if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit;
 
     	print_barre_liste($langs->trans("ActionsOnMember"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', '', $newcardbutton, '', 0, 1, 1);
 
     	// List of all actions
-    	$filters=array();
-    	$filters['search_agenda_label']=$search_agenda_label;
+    	$filters = array();
+    	$filters['search_agenda_label'] = $search_agenda_label;
 
     	// TODO Replace this with same code than into list.php
     	show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder);

+ 35 - 35
htdocs/adherents/canvas/actions_adherentcard_common.class.php

@@ -45,7 +45,7 @@ abstract class ActionsAdherentCardCommon
 	/**
 	 * @var string Error code (or message)
 	 */
-	public $error='';
+	public $error = '';
 
 	/**
 	 * @var string[] Error codes (or messages)
@@ -70,7 +70,7 @@ abstract class ActionsAdherentCardCommon
     	else
     	{*/
     		$object = new Adherent($this->db);
-    		if (! empty($id)) $object->fetch($id);
+    		if (!empty($id)) $object->fetch($id);
             $this->object = $object;
     	//}
     }
@@ -91,13 +91,13 @@ abstract class ActionsAdherentCardCommon
 
         if ($action == 'add' || $action == 'update') $this->assign_post();
 
-        foreach($this->object as $key => $value)
+        foreach ($this->object as $key => $value)
         {
             $this->tpl[$key] = $value;
         }
 
-        $this->tpl['error']=$this->error;
-        $this->tpl['errors']=$this->errors;
+        $this->tpl['error'] = $this->error;
+        $this->tpl['errors'] = $this->errors;
 
         if ($action == 'create' || $action == 'edit')
         {
@@ -139,10 +139,10 @@ abstract class ActionsAdherentCardCommon
         	}
 
             // Zip
-            $this->tpl['select_zip'] = $formcompany->select_ziptown($this->object->zip, 'zipcode', array('town','selectcountry_id','state_id'), 6);
+            $this->tpl['select_zip'] = $formcompany->select_ziptown($this->object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6);
 
             // Town
-            $this->tpl['select_town'] = $formcompany->select_ziptown($this->object->town, 'town', array('zipcode','selectcountry_id','state_id'));
+            $this->tpl['select_town'] = $formcompany->select_ziptown($this->object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id'));
 
             if (dol_strlen(trim($this->object->country_id)) == 0) $this->object->country_id = $objsoc->country_id;
 
@@ -157,14 +157,14 @@ abstract class ActionsAdherentCardCommon
             else $this->tpl['select_state'] = $countrynotdefined;
 
             // Physical or Moral
-            $selectarray=array('0'=>$langs->trans("Physical"),'1'=>$langs->trans("Moral"));
+            $selectarray = array('0'=>$langs->trans("Physical"), '1'=>$langs->trans("Moral"));
             $this->tpl['select_morphy'] = $form->selectarray('morphy', $selectarray, $this->object->morphy, 0);
         }
 
         if ($action == 'view' || $action == 'edit' || $action == 'delete')
         {
         	// Emailing
-        	if (! empty($conf->mailing->enabled))
+        	if (!empty($conf->mailing->enabled))
 			{
 				$langs->load("mails");
 				$this->tpl['nb_emailing'] = $this->object->getNbOfEMailings();
@@ -173,8 +173,8 @@ abstract class ActionsAdherentCardCommon
         	// Dolibarr user
         	if ($this->object->user_id)
 			{
-				$dolibarr_user=new User($this->db);
-				$result=$dolibarr_user->fetch($this->object->user_id);
+				$dolibarr_user = new User($this->db);
+				$result = $dolibarr_user->fetch($this->object->user_id);
 				$this->tpl['dolibarr_user'] = $dolibarr_user->getLoginUrl(1);
 			}
 			else $this->tpl['dolibarr_user'] = $langs->trans("NoDolibarrAccess");
@@ -200,14 +200,14 @@ abstract class ActionsAdherentCardCommon
 
             $this->tpl['address'] = dol_nl2br($this->object->address);
 
-            $this->tpl['zip'] = ($this->object->zip?$this->object->zip.'&nbsp;':'');
+            $this->tpl['zip'] = ($this->object->zip ? $this->object->zip.'&nbsp;' : '');
 
-            $img=picto_from_langcode($this->object->country_code);
-            $this->tpl['country'] = ($img?$img.' ':'').$this->object->country;
+            $img = picto_from_langcode($this->object->country_code);
+            $this->tpl['country'] = ($img ? $img.' ' : '').$this->object->country;
 
-            $this->tpl['phone_perso'] 	= dol_print_phone($this->object->phone_perso, $this->object->country_code, 0, $this->object->id, 'AC_TEL');
-            $this->tpl['phone_mobile'] 	= dol_print_phone($this->object->phone_mobile, $this->object->country_code, 0, $this->object->id, 'AC_TEL');
-            $this->tpl['email'] 		= dol_print_email($this->object->email, 0, $this->object->id, 'AC_EMAIL');
+            $this->tpl['phone_perso'] = dol_print_phone($this->object->phone_perso, $this->object->country_code, 0, $this->object->id, 'AC_TEL');
+            $this->tpl['phone_mobile'] = dol_print_phone($this->object->phone_mobile, $this->object->country_code, 0, $this->object->id, 'AC_TEL');
+            $this->tpl['email'] = dol_print_email($this->object->email, 0, $this->object->id, 'AC_EMAIL');
 
             $this->tpl['visibility'] = $this->object->getmorphylib($this->object->morphy);
 
@@ -219,13 +219,13 @@ abstract class ActionsAdherentCardCommon
         	// Full firstname and lastname separated with a dot : firstname.lastname
         	include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
             require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
-        	$login=dol_buildlogin($this->object->lastname, $this->object->firstname);
+        	$login = dol_buildlogin($this->object->lastname, $this->object->firstname);
 
-       		$generated_password=getRandomPassword(false);
-        	$password=$generated_password;
+       		$generated_password = getRandomPassword(false);
+        	$password = $generated_password;
 
         	// Create a form array
-        	$formquestion=array(
+        	$formquestion = array(
         	array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login),
         	array('label' => $langs->trans("Password"), 'type' => 'text', 'name' => 'password', 'value' => $password));
 
@@ -244,35 +244,35 @@ abstract class ActionsAdherentCardCommon
         // phpcs:enable
         global $langs, $mysoc;
 
-        $this->object->old_name 		= $_POST["old_name"];
-        $this->object->old_firstname 	= $_POST["old_firstname"];
+        $this->object->old_name = $_POST["old_name"];
+        $this->object->old_firstname = $_POST["old_firstname"];
 
-        $this->object->fk_soc			= $_POST["fk_soc"];
+        $this->object->fk_soc = $_POST["fk_soc"];
         $this->object->lastname			= $_POST["lastname"];
         $this->object->firstname		= $_POST["firstname"];
-        $this->object->civility_id		= $_POST["civility_id"];
-        $this->object->address			= $_POST["address"];
-        $this->object->zip				= $_POST["zipcode"];
-        $this->object->town				= $_POST["town"];
-        $this->object->country_id		= $_POST["country_id"]?$_POST["country_id"]:$mysoc->country_id;
-        $this->object->state_id        	= $_POST["state_id"];
-        $this->object->phone_perso		= $_POST["phone_perso"];
-        $this->object->phone_mobile		= $_POST["phone_mobile"];
+        $this->object->civility_id = $_POST["civility_id"];
+        $this->object->address = $_POST["address"];
+        $this->object->zip = $_POST["zipcode"];
+        $this->object->town = $_POST["town"];
+        $this->object->country_id = $_POST["country_id"] ? $_POST["country_id"] : $mysoc->country_id;
+        $this->object->state_id = $_POST["state_id"];
+        $this->object->phone_perso = $_POST["phone_perso"];
+        $this->object->phone_mobile = $_POST["phone_mobile"];
         $this->object->email			= $_POST["email"];
         $this->object->note				= $_POST["note"];
-        $this->object->canvas			= $_POST["canvas"];
+        $this->object->canvas = $_POST["canvas"];
 
         // We set country_id, and country_code label of the chosen country
         if ($this->object->country_id)
         {
             $sql = "SELECT code, label FROM ".MAIN_DB_PREFIX."c_country WHERE rowid = ".$this->object->country_id;
-            $resql=$this->db->query($sql);
+            $resql = $this->db->query($sql);
             if ($resql)
             {
                 $obj = $this->db->fetch_object($resql);
 
                 $this->object->country_code = $obj->code;
-                $this->object->country = $langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->libelle;
+                $this->object->country = $langs->trans("Country".$obj->code) ? $langs->trans("Country".$obj->code) : $obj->libelle;
             }
             else
             {

+ 11 - 11
htdocs/adherents/canvas/default/actions_adherentcard_default.class.php

@@ -42,7 +42,7 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon
 	public function __construct($db, $dirmodule, $targetmodule, $canvas, $card)
 	{
         $this->db               = $db;
-        $this->dirmodule		= $dirmodule;
+        $this->dirmodule = $dirmodule;
         $this->targetmodule     = $targetmodule;
         $this->canvas           = $canvas;
         $this->card             = $card;
@@ -56,13 +56,13 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon
 	 */
 	private function getTitle($action)
 	{
-		global $langs,$conf;
+		global $langs, $conf;
 
-		$out='';
+		$out = '';
 
-		if ($action == 'view') 		$out.= (! empty($conf->global->ADHERENT_ADDRESSES_MANAGEMENT) ? $langs->trans("Adherent") : $langs->trans("ContactAddress"));
-		if ($action == 'edit') 		$out.= (! empty($conf->global->ADHERENT_ADDRESSES_MANAGEMENT) ? $langs->trans("EditAdherent") : $langs->trans("EditAdherentAddress"));
-		if ($action == 'create')	$out.= (! empty($conf->global->ADHERENT_ADDRESSES_MANAGEMENT) ? $langs->trans("NewAdherent") : $langs->trans("NewAdherentAddress"));
+		if ($action == 'view') 		$out .= (!empty($conf->global->ADHERENT_ADDRESSES_MANAGEMENT) ? $langs->trans("Adherent") : $langs->trans("ContactAddress"));
+		if ($action == 'edit') 		$out .= (!empty($conf->global->ADHERENT_ADDRESSES_MANAGEMENT) ? $langs->trans("EditAdherent") : $langs->trans("EditAdherentAddress"));
+		if ($action == 'create')	$out .= (!empty($conf->global->ADHERENT_ADDRESSES_MANAGEMENT) ? $langs->trans("NewAdherent") : $langs->trans("NewAdherentAddress"));
 
 		return $out;
 	}
@@ -88,7 +88,7 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon
 
         $this->tpl['title'] = $this->getTitle($action);
         $this->tpl['error'] = $this->error;
-        $this->tpl['errors']= $this->errors;
+        $this->tpl['errors'] = $this->errors;
 
 		if ($action == 'view')
 		{
@@ -96,15 +96,15 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon
             $head = member_prepare_head($this->object);
             $title = $this->getTitle($action);
 
-		    $this->tpl['showhead']=dol_get_fiche_head($head, 'card', $title, 0, 'adherent');
-		    $this->tpl['showend']=dol_get_fiche_end();
+		    $this->tpl['showhead'] = dol_get_fiche_head($head, 'card', $title, 0, 'adherent');
+		    $this->tpl['showend'] = dol_get_fiche_end();
 
         	$objsoc = new Societe($db);
             $objsoc->fetch($this->object->socid);
 
-            $this->tpl['actionstodo']=show_actions_todo($conf, $langs, $db, $objsoc, $this->object, 1);
+            $this->tpl['actionstodo'] = show_actions_todo($conf, $langs, $db, $objsoc, $this->object, 1);
 
-            $this->tpl['actionsdone']=show_actions_done($conf, $langs, $db, $objsoc, $this->object, 1);
+            $this->tpl['actionsdone'] = show_actions_done($conf, $langs, $db, $objsoc, $this->object, 1);
 		}
 		else
 		{

+ 3 - 3
htdocs/adherents/canvas/default/tpl/adherentcard_create.tpl.php

@@ -17,7 +17,7 @@
  */
 
 // Protection to avoid direct call of template
-if (empty($conf) || ! is_object($conf))
+if (empty($conf) || !is_object($conf))
 {
 	print "Error, template page can't be called as URL";
 	exit;
@@ -30,9 +30,9 @@ if (empty($conf) || ! is_object($conf))
 <?php
 print load_fiche_titre($this->control->tpl['title']);
 
-dol_htmloutput_errors((is_numeric($object->error)?'':$object->error), $object->errors);
+dol_htmloutput_errors((is_numeric($object->error) ? '' : $object->error), $object->errors);
 
-dol_htmloutput_errors((is_numeric($GLOBALS['error'])?'':$GLOBALS['error']), $GLOBALS['errors']);
+dol_htmloutput_errors((is_numeric($GLOBALS['error']) ? '' : $GLOBALS['error']), $GLOBALS['errors']);
 
 dol_htmloutput_errors($this->control->tpl['error'], $this->control->tpl['errors']);
 

+ 2 - 2
htdocs/adherents/canvas/default/tpl/adherentcard_edit.tpl.php

@@ -17,7 +17,7 @@
  */
 
 // Protection to avoid direct call of template
-if (empty($conf) || ! is_object($conf))
+if (empty($conf) || !is_object($conf))
 {
 	print "Error, template page can't be called as URL";
 	exit;
@@ -48,7 +48,7 @@ echo $this->control->tpl['ajax_selectcountry'];
 <input type="hidden" name="adherentid" value="<?php echo $this->control->tpl['id']; ?>">
 <input type="hidden" name="old_name" value="<?php echo $this->control->tpl['name']; ?>">
 <input type="hidden" name="old_firstname" value="<?php echo $this->control->tpl['firstname']; ?>">
-<?php if (! empty($this->control->tpl['company_id'])) { ?>
+<?php if (!empty($this->control->tpl['company_id'])) { ?>
 <input type="hidden" name="socid" value="<?php echo $this->control->tpl['company_id']; ?>">
 <?php } ?>
 

+ 4 - 4
htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php

@@ -17,7 +17,7 @@
  */
 
 // Protection to avoid direct call of template
-if (empty($conf) || ! is_object($conf))
+if (empty($conf) || !is_object($conf))
 {
 	print "Error, template page can't be called as URL";
 	exit;
@@ -30,8 +30,8 @@ echo "<!-- BEGIN PHP TEMPLATE ADHERENTCARD_VIEW.TPL.PHP DEFAULT -->\n";
 echo $this->control->tpl['showhead'];
 
 dol_htmloutput_errors($this->control->tpl['error'], $this->control->tpl['errors']);
-if (! empty($this->control->tpl['action_create_user'])) echo $this->control->tpl['action_create_user'];
-if (! empty($this->control->tpl['action_delete'])) echo $this->control->tpl['action_delete']; ?>
+if (!empty($this->control->tpl['action_create_user'])) echo $this->control->tpl['action_create_user'];
+if (!empty($this->control->tpl['action_delete'])) echo $this->control->tpl['action_delete']; ?>
 
 <table class="border allwidth">
 
@@ -125,7 +125,7 @@ if (empty($user->socid)) {
         echo '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$this->control->tpl['id'].'&amp;action=edit&amp;canvas='.$canvas.'">'.$langs->trans('Modify').'</a>';
     }
 
-    if (! $this->control->tpl['user_id'] && $user->rights->user->user->creer) {
+    if (!$this->control->tpl['user_id'] && $user->rights->user->user->creer) {
         echo '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$this->control->tpl['id'].'&amp;action=create_user&amp;canvas='.$canvas.'">'.$langs->trans("CreateDolibarrLogin").'</a>';
     }
 

+ 79 - 79
htdocs/adherents/cartes/carte.php

@@ -29,22 +29,22 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
 require_once DOL_DOCUMENT_ROOT.'/core/modules/member/modules_cards.php';
 require_once DOL_DOCUMENT_ROOT.'/core/modules/printsheet/modules_labels.php';
 
-$langs->loadLangs(array("members","errors"));
+$langs->loadLangs(array("members", "errors"));
 
 // Choice of printing year or current year.
 $now = dol_now();
-$year=dol_print_date($now, '%Y');
-$month=dol_print_date($now, '%m');
-$day=dol_print_date($now, '%d');
-$foruserid=GETPOST('foruserid', 'alphanohtml');
-$foruserlogin=GETPOST('foruserlogin', 'alphanohtml');
-$mode=GETPOST('mode', 'aZ09');
-$model=GETPOST("model", 'aZ09');				// Doc template to use for business cards
-$modellabel=GETPOST("modellabel", 'aZ09');	// Doc template to use for address sheet
-$mesg='';
-
-$adherentstatic=new Adherent($db);
-$object=new Adherent($db);
+$year = dol_print_date($now, '%Y');
+$month = dol_print_date($now, '%m');
+$day = dol_print_date($now, '%d');
+$foruserid = GETPOST('foruserid', 'alphanohtml');
+$foruserlogin = GETPOST('foruserlogin', 'alphanohtml');
+$mode = GETPOST('mode', 'aZ09');
+$model = GETPOST("model", 'aZ09'); // Doc template to use for business cards
+$modellabel = GETPOST("modellabel", 'aZ09'); // Doc template to use for address sheet
+$mesg = '';
+
+$adherentstatic = new Adherent($db);
+$object = new Adherent($db);
 
 $extrafields = new ExtraFields($db);
 // Fetch optionals attributes and labels
@@ -57,29 +57,29 @@ $extrafields->fetch_name_optionals_label($object->table_element);
 
 if ($mode == 'cardlogin' && empty($foruserlogin))
 {
-    $mesg=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Login"));
+    $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Login"));
 }
 
-if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg)
+if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg)
 {
-    $arrayofmembers=array();
+    $arrayofmembers = array();
 
     // request taking into account member with up to date subscriptions
     $sql = "SELECT d.rowid, d.firstname, d.lastname, d.login, d.societe as company, d.datefin,";
-    $sql.= " d.address, d.zip, d.town, d.country, d.birth, d.email, d.photo,";
-    $sql.= " t.libelle as type,";
-    $sql.= " c.code as country_code, c.label as country";
+    $sql .= " d.address, d.zip, d.town, d.country, d.birth, d.email, d.photo,";
+    $sql .= " t.libelle as type,";
+    $sql .= " c.code as country_code, c.label as country";
     // Add fields from extrafields
-    if (! empty($extrafields->attributes[$object->table_element]['label']))
-    	foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
-    $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d";
-    $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.country = c.rowid";
-    if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_extrafields as ef on (d.rowid = ef.fk_object)";
-    $sql.= " WHERE d.fk_adherent_type = t.rowid AND d.statut = 1";
-    $sql.= " AND d.entity IN (".getEntity('adherent').")";
-    if (is_numeric($foruserid)) $sql.=" AND d.rowid=".$foruserid;
-    if ($foruserlogin) $sql.=" AND d.login='".$db->escape($foruserlogin)."'";
-    $sql.= " ORDER BY d.rowid ASC";
+    if (!empty($extrafields->attributes[$object->table_element]['label']))
+    	foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
+    $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d";
+    $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.country = c.rowid";
+    if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_extrafields as ef on (d.rowid = ef.fk_object)";
+    $sql .= " WHERE d.fk_adherent_type = t.rowid AND d.statut = 1";
+    $sql .= " AND d.entity IN (".getEntity('adherent').")";
+    if (is_numeric($foruserid)) $sql .= " AND d.rowid=".$foruserid;
+    if ($foruserlogin) $sql .= " AND d.login='".$db->escape($foruserlogin)."'";
+    $sql .= " ORDER BY d.rowid ASC";
 
     dol_syslog("Search members", LOG_DEBUG);
     $result = $db->query($sql);
@@ -91,19 +91,19 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg
     	{
     		$objp = $db->fetch_object($result);
 
-    		if ($objp->country == '-') $objp->country='';
+    		if ($objp->country == '-') $objp->country = '';
 
-    		$adherentstatic->id=$objp->rowid;
-    		$adherentstatic->lastname=$objp->lastname;
-    		$adherentstatic->firstname=$objp->firstname;
+    		$adherentstatic->id = $objp->rowid;
+    		$adherentstatic->lastname = $objp->lastname;
+    		$adherentstatic->firstname = $objp->firstname;
 
             // Format extrafield so they can be parsed in function complete_substitutions_array
     		if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']))
             {
                 $adherentstatic->array_options = array();
-                foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val)
+                foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val)
                 {
-                    $tmpkey='options_'.$key;
+                    $tmpkey = 'options_'.$key;
                     if (!empty($objp->$tmpkey))
                     {
                         $adherentstatic->array_options[$tmpkey] = $objp->$tmpkey;
@@ -115,7 +115,7 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg
             }
 
     		// List of values to scan for a replacement
-            $substitutionarray = array (
+            $substitutionarray = array(
                 '__ID__'=>$objp->rowid,
                 '__LOGIN__'=>$objp->login,
                 '__FIRSTNAME__'=>$objp->firstname,
@@ -139,21 +139,21 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg
             complete_substitutions_array($substitutionarray, $langs, $adherentstatic);
 
             // For business cards
-            if (empty($mode) || $mode=='card' || $mode=='cardlogin')
+            if (empty($mode) || $mode == 'card' || $mode == 'cardlogin')
             {
-                $textleft=make_substitutions($conf->global->ADHERENT_CARD_TEXT, $substitutionarray);
-                $textheader=make_substitutions($conf->global->ADHERENT_CARD_HEADER_TEXT, $substitutionarray);
-                $textfooter=make_substitutions($conf->global->ADHERENT_CARD_FOOTER_TEXT, $substitutionarray);
-                $textright=make_substitutions($conf->global->ADHERENT_CARD_TEXT_RIGHT, $substitutionarray);
+                $textleft = make_substitutions($conf->global->ADHERENT_CARD_TEXT, $substitutionarray);
+                $textheader = make_substitutions($conf->global->ADHERENT_CARD_HEADER_TEXT, $substitutionarray);
+                $textfooter = make_substitutions($conf->global->ADHERENT_CARD_FOOTER_TEXT, $substitutionarray);
+                $textright = make_substitutions($conf->global->ADHERENT_CARD_TEXT_RIGHT, $substitutionarray);
 
                 if (is_numeric($foruserid) || $foruserlogin)
                 {
                     $nb = $_Avery_Labels[$model]['NX'] * $_Avery_Labels[$model]['NY'];
-                    if ($nb <= 0) $nb=1;  // Protection to avoid empty page
+                    if ($nb <= 0) $nb = 1; // Protection to avoid empty page
 
-                    for($j=0;$j<$nb;$j++)
+                    for ($j = 0; $j < $nb; $j++)
                     {
-                        $arrayofmembers[]=array(
+                        $arrayofmembers[] = array(
                         	'textleft'=>$textleft,
                             'textheader'=>$textheader,
                             'textfooter'=>$textfooter,
@@ -165,7 +165,7 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg
                 }
                 else
                 {
-                    $arrayofmembers[]=array(
+                    $arrayofmembers[] = array(
                     	'textleft'=>$textleft,
                         'textheader'=>$textheader,
                         'textfooter'=>$textfooter,
@@ -179,13 +179,13 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg
             // For labels
             if ($mode == 'label')
             {
-            	if (empty($conf->global->ADHERENT_ETIQUETTE_TEXT)) $conf->global->ADHERENT_ETIQUETTE_TEXT="__FULLNAME__\n__ADDRESS__\n__ZIP__ __TOWN__\n__COUNTRY__";
-                $textleft=make_substitutions($conf->global->ADHERENT_ETIQUETTE_TEXT, $substitutionarray);
-                $textheader='';
-                $textfooter='';
-                $textright='';
+            	if (empty($conf->global->ADHERENT_ETIQUETTE_TEXT)) $conf->global->ADHERENT_ETIQUETTE_TEXT = "__FULLNAME__\n__ADDRESS__\n__ZIP__ __TOWN__\n__COUNTRY__";
+                $textleft = make_substitutions($conf->global->ADHERENT_ETIQUETTE_TEXT, $substitutionarray);
+                $textheader = '';
+                $textfooter = '';
+                $textright = '';
 
-                $arrayofmembers[]=array('textleft'=>$textleft,
+                $arrayofmembers[] = array('textleft'=>$textleft,
                                         'textheader'=>$textheader,
                                         'textfooter'=>$textfooter,
                                         'textright'=>$textright,
@@ -197,29 +197,29 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg
     	}
 
     	// Build and output PDF
-        if (empty($mode) || $mode=='card' || $mode=='cardlogin')
+        if (empty($mode) || $mode == 'card' || $mode == 'cardlogin')
         {
-            if (! count($arrayofmembers))
+            if (!count($arrayofmembers))
             {
-                $mesg=$langs->trans("ErrorRecordNotFound");
+                $mesg = $langs->trans("ErrorRecordNotFound");
             }
             if (empty($model) || $model == '-1')
             {
-            	$mesg=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DescADHERENT_CARD_TYPE"));
+            	$mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DescADHERENT_CARD_TYPE"));
             }
-            if (! $mesg) $result=members_card_pdf_create($db, $arrayofmembers, $model, $outputlangs);
+            if (!$mesg) $result = members_card_pdf_create($db, $arrayofmembers, $model, $outputlangs);
         }
         elseif ($mode == 'label')
         {
-            if (! count($arrayofmembers))
+            if (!count($arrayofmembers))
             {
-                $mesg=$langs->trans("ErrorRecordNotFound");
+                $mesg = $langs->trans("ErrorRecordNotFound");
             }
         	if (empty($modellabel) || $modellabel == '-1')
     		{
-    			$mesg=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DescADHERENT_ETIQUETTE_TYPE"));
+    			$mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DescADHERENT_ETIQUETTE_TYPE"));
     		}
-        	if (! $mesg) $result=doc_label_pdf_create($db, $arrayofmembers, $modellabel, $outputlangs);
+        	if (!$mesg) $result = doc_label_pdf_create($db, $arrayofmembers, $modellabel, $outputlangs);
         }
 
     	if ($result <= 0)
@@ -232,7 +232,7 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg
     	dol_print_error($db);
     }
 
-    if (! $mesg)
+    if (!$mesg)
     {
     	$db->close();
     	exit;
@@ -244,7 +244,7 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg
  * View
  */
 
-$form=new Form($db);
+$form = new Form($db);
 
 llxHeader('', $langs->trans("MembersCards"));
 
@@ -257,40 +257,40 @@ dol_htmloutput_errors($mesg);
 
 print '<br>';
 
-print img_picto('', 'puce').' '.$langs->trans("DocForAllMembersCards", ($conf->global->ADHERENT_CARD_TYPE?$conf->global->ADHERENT_CARD_TYPE:$langs->transnoentitiesnoconv("None"))).' ';
+print img_picto('', 'puce').' '.$langs->trans("DocForAllMembersCards", ($conf->global->ADHERENT_CARD_TYPE ? $conf->global->ADHERENT_CARD_TYPE : $langs->transnoentitiesnoconv("None"))).' ';
 print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
-print '<input type="hidden" name="token" value="' . newToken() . '">';
+print '<input type="hidden" name="token" value="'.newToken().'">';
 print '<input type="hidden" name="foruserid" value="all">';
 print '<input type="hidden" name="mode" value="card">';
 print '<input type="hidden" name="action" value="builddoc">';
 print $langs->trans("DescADHERENT_CARD_TYPE").' ';
 // List of possible labels (defined into $_Avery_Labels variable set into format_cards.lib.php)
-$arrayoflabels=array();
-foreach(array_keys($_Avery_Labels) as $codecards)
+$arrayoflabels = array();
+foreach (array_keys($_Avery_Labels) as $codecards)
 {
-	$arrayoflabels[$codecards]=$_Avery_Labels[$codecards]['name'];
+	$arrayoflabels[$codecards] = $_Avery_Labels[$codecards]['name'];
 }
 asort($arrayoflabels);
-print $form->selectarray('model', $arrayoflabels, (GETPOST('model')?GETPOST('model'):$conf->global->ADHERENT_CARD_TYPE), 1, 0, 0, '', 0, 0, 0, '', '', 1);
+print $form->selectarray('model', $arrayoflabels, (GETPOST('model') ?GETPOST('model') : $conf->global->ADHERENT_CARD_TYPE), 1, 0, 0, '', 0, 0, 0, '', '', 1);
 print '<br><input class="button" type="submit" value="'.$langs->trans("BuildDoc").'">';
 print '</form>';
 
 print '<br><br>';
 
-print img_picto('', 'puce').' '.$langs->trans("DocForOneMemberCards", ($conf->global->ADHERENT_CARD_TYPE?$conf->global->ADHERENT_CARD_TYPE:$langs->transnoentitiesnoconv("None"))).' ';
+print img_picto('', 'puce').' '.$langs->trans("DocForOneMemberCards", ($conf->global->ADHERENT_CARD_TYPE ? $conf->global->ADHERENT_CARD_TYPE : $langs->transnoentitiesnoconv("None"))).' ';
 print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
-print '<input type="hidden" name="token" value="' . newToken() . '">';
+print '<input type="hidden" name="token" value="'.newToken().'">';
 print '<input type="hidden" name="mode" value="cardlogin">';
 print '<input type="hidden" name="action" value="builddoc">';
 print $langs->trans("DescADHERENT_CARD_TYPE").' ';
 // List of possible labels (defined into $_Avery_Labels variable set into format_cards.lib.php)
-$arrayoflabels=array();
-foreach(array_keys($_Avery_Labels) as $codecards)
+$arrayoflabels = array();
+foreach (array_keys($_Avery_Labels) as $codecards)
 {
-	$arrayoflabels[$codecards]=$_Avery_Labels[$codecards]['name'];
+	$arrayoflabels[$codecards] = $_Avery_Labels[$codecards]['name'];
 }
 asort($arrayoflabels);
-print $form->selectarray('model', $arrayoflabels, (GETPOST('model')?GETPOST('model'):$conf->global->ADHERENT_CARD_TYPE), 1, 0, 0, '', 0, 0, 0, '', '', 1);
+print $form->selectarray('model', $arrayoflabels, (GETPOST('model') ?GETPOST('model') : $conf->global->ADHERENT_CARD_TYPE), 1, 0, 0, '', 0, 0, 0, '', '', 1);
 print '<br>'.$langs->trans("Login").': <input size="10" type="text" name="foruserlogin" value="'.GETPOST('foruserlogin').'">';
 print '<br><input class="button" type="submit" value="'.$langs->trans("BuildDoc").'">';
 print '</form>';
@@ -299,18 +299,18 @@ print '<br><br>';
 
 print img_picto('', 'puce').' '.$langs->trans("DocForLabels", $conf->global->ADHERENT_ETIQUETTE_TYPE).' ';
 print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
-print '<input type="hidden" name="token" value="' . newToken() . '">';
+print '<input type="hidden" name="token" value="'.newToken().'">';
 print '<input type="hidden" name="mode" value="label">';
 print '<input type="hidden" name="action" value="builddoc">';
 print $langs->trans("DescADHERENT_ETIQUETTE_TYPE").' ';
 // List of possible labels (defined into $_Avery_Labels variable set into format_cards.lib.php)
-$arrayoflabels=array();
-foreach(array_keys($_Avery_Labels) as $codecards)
+$arrayoflabels = array();
+foreach (array_keys($_Avery_Labels) as $codecards)
 {
-	$arrayoflabels[$codecards]=$_Avery_Labels[$codecards]['name'];
+	$arrayoflabels[$codecards] = $_Avery_Labels[$codecards]['name'];
 }
 asort($arrayoflabels);
-print $form->selectarray('modellabel', $arrayoflabels, (GETPOST('modellabel')?GETPOST('modellabel'):$conf->global->ADHERENT_ETIQUETTE_TYPE), 1, 0, 0, '', 0, 0, 0, '', '', 1);
+print $form->selectarray('modellabel', $arrayoflabels, (GETPOST('modellabel') ?GETPOST('modellabel') : $conf->global->ADHERENT_ETIQUETTE_TYPE), 1, 0, 0, '', 0, 0, 0, '', '', 1);
 print '<br><input class="button" type="submit" value="'.$langs->trans("BuildDoc").'">';
 print '</form>';
 

+ 31 - 31
htdocs/adherents/class/adherentstats.class.php

@@ -23,8 +23,8 @@
  *	\brief      Fichier de la classe de gestion des stats des adhérents
  */
 
-include_once DOL_DOCUMENT_ROOT . '/core/class/stats.class.php';
-include_once DOL_DOCUMENT_ROOT . '/adherents/class/subscription.class.php';
+include_once DOL_DOCUMENT_ROOT.'/core/class/stats.class.php';
+include_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php';
 
 
 /**
@@ -61,17 +61,17 @@ class AdherentStats extends Stats
         $this->socid = $socid;
         $this->userid = $userid;
 
-		$object=new Subscription($this->db);
+		$object = new Subscription($this->db);
 
 		$this->from = MAIN_DB_PREFIX.$object->table_element." as p";
-		$this->from.= ", ".MAIN_DB_PREFIX."adherent as m";
+		$this->from .= ", ".MAIN_DB_PREFIX."adherent as m";
 
-		$this->field='subscription';
+		$this->field = 'subscription';
 
-		$this->where.= " m.statut != 0";
-		$this->where.= " AND p.fk_adherent = m.rowid AND m.entity IN (".getEntity('adherent').")";
+		$this->where .= " m.statut != 0";
+		$this->where .= " AND p.fk_adherent = m.rowid AND m.entity IN (".getEntity('adherent').")";
 		//if (!$user->rights->societe->client->voir && !$user->socid) $this->where .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
-		if($this->memberid)
+		if ($this->memberid)
 		{
 			$this->where .= " AND m.rowid = ".$this->memberid;
 		}
@@ -91,12 +91,12 @@ class AdherentStats extends Stats
 		global $user;
 
 		$sql = "SELECT date_format(p.dateadh,'%m') as dm, count(*)";
-		$sql.= " FROM ".$this->from;
+		$sql .= " FROM ".$this->from;
 		//if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-		$sql.= " WHERE date_format(p.dateadh,'%Y') = '".$year."'";
-		$sql.= " AND ".$this->where;
-		$sql.= " GROUP BY dm";
-        $sql.= $this->db->order('dm', 'DESC');
+		$sql .= " WHERE date_format(p.dateadh,'%Y') = '".$year."'";
+		$sql .= " AND ".$this->where;
+		$sql .= " GROUP BY dm";
+        $sql .= $this->db->order('dm', 'DESC');
 
 		return $this->_getNbByMonth($year, $sql, $format);
 	}
@@ -111,11 +111,11 @@ class AdherentStats extends Stats
 		global $user;
 
 		$sql = "SELECT date_format(p.dateadh,'%Y') as dm, count(*)";
-		$sql.= " FROM ".$this->from;
+		$sql .= " FROM ".$this->from;
 		//if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-		$sql.= " WHERE ".$this->where;
-		$sql.= " GROUP BY dm";
-        $sql.= $this->db->order('dm', 'DESC');
+		$sql .= " WHERE ".$this->where;
+		$sql .= " GROUP BY dm";
+        $sql .= $this->db->order('dm', 'DESC');
 
 		return $this->_getNbByYear($sql);
 	}
@@ -132,12 +132,12 @@ class AdherentStats extends Stats
 		global $user;
 
 		$sql = "SELECT date_format(p.dateadh,'%m') as dm, sum(p.".$this->field.")";
-		$sql.= " FROM ".$this->from;
+		$sql .= " FROM ".$this->from;
 		//if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-		$sql.= " WHERE date_format(p.dateadh,'%Y') = '".$year."'";
-		$sql.= " AND ".$this->where;
-		$sql.= " GROUP BY dm";
-        $sql.= $this->db->order('dm', 'DESC');
+		$sql .= " WHERE date_format(p.dateadh,'%Y') = '".$year."'";
+		$sql .= " AND ".$this->where;
+		$sql .= " GROUP BY dm";
+        $sql .= $this->db->order('dm', 'DESC');
 
 		return $this->_getAmountByMonth($year, $sql, $format);
 	}
@@ -153,12 +153,12 @@ class AdherentStats extends Stats
 		global $user;
 
 		$sql = "SELECT date_format(p.dateadh,'%m') as dm, avg(p.".$this->field.")";
-		$sql.= " FROM ".$this->from;
+		$sql .= " FROM ".$this->from;
 		//if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-		$sql.= " WHERE date_format(p.dateadh,'%Y') = '".$year."'";
-		$sql.= " AND ".$this->where;
-		$sql.= " GROUP BY dm";
-        $sql.= $this->db->order('dm', 'DESC');
+		$sql .= " WHERE date_format(p.dateadh,'%Y') = '".$year."'";
+		$sql .= " AND ".$this->where;
+		$sql .= " GROUP BY dm";
+        $sql .= $this->db->order('dm', 'DESC');
 
 		return $this->_getAverageByMonth($year, $sql);
 	}
@@ -174,11 +174,11 @@ class AdherentStats extends Stats
 		global $user;
 
 		$sql = "SELECT date_format(p.dateadh,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg";
-		$sql.= " FROM ".$this->from;
+		$sql .= " FROM ".$this->from;
 		//if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-		$sql.= " WHERE ".$this->where;
-		$sql.= " GROUP BY year";
-        $sql.= $this->db->order('year', 'DESC');
+		$sql .= " WHERE ".$this->where;
+		$sql .= " GROUP BY year";
+        $sql .= $this->db->order('year', 'DESC');
 
 		return $this->_getAllByYear($sql);
 	}

+ 31 - 31
htdocs/adherents/class/api_members.class.php

@@ -59,17 +59,17 @@ class Members extends DolibarrApi
      */
     public function get($id)
     {
-        if(! DolibarrApiAccess::$user->rights->adherent->lire) {
+        if (!DolibarrApiAccess::$user->rights->adherent->lire) {
             throw new RestException(401);
         }
 
         $member = new Adherent($this->db);
         $result = $member->fetch($id);
-        if( ! $result ) {
+        if (!$result) {
             throw new RestException(404, 'member not found');
         }
 
-        if( ! DolibarrApi::_checkAccessToResource('adherent', $member->id)) {
+        if (!DolibarrApi::_checkAccessToResource('adherent', $member->id)) {
             throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
         }
 
@@ -98,50 +98,50 @@ class Members extends DolibarrApi
 
         $obj_ret = array();
 
-        if(! DolibarrApiAccess::$user->rights->adherent->lire) {
+        if (!DolibarrApiAccess::$user->rights->adherent->lire) {
             throw new RestException(401);
         }
 
         $sql = "SELECT t.rowid";
-        $sql.= " FROM ".MAIN_DB_PREFIX."adherent as t";
-        $sql.= ' WHERE t.entity IN ('.getEntity('adherent').')';
+        $sql .= " FROM ".MAIN_DB_PREFIX."adherent as t";
+        $sql .= ' WHERE t.entity IN ('.getEntity('adherent').')';
         if (!empty($typeid))
         {
-            $sql.= ' AND t.fk_adherent_type='.$typeid;
+            $sql .= ' AND t.fk_adherent_type='.$typeid;
         }
         // Add sql filters
         if ($sqlfilters)
         {
-            if (! DolibarrApi::_checkFilters($sqlfilters))
+            if (!DolibarrApi::_checkFilters($sqlfilters))
             {
                 throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
             }
-	        $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
-            $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
+	        $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
+            $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
         }
 
-        $sql.= $db->order($sortfield, $sortorder);
-        if ($limit)    {
+        $sql .= $db->order($sortfield, $sortorder);
+        if ($limit) {
             if ($page < 0)
             {
                 $page = 0;
             }
             $offset = $limit * $page;
 
-            $sql.= $db->plimit($limit + 1, $offset);
+            $sql .= $db->plimit($limit + 1, $offset);
         }
 
         $result = $db->query($sql);
         if ($result)
         {
-            $i=0;
+            $i = 0;
             $num = $db->num_rows($result);
             $min = min($num, ($limit <= 0 ? $num : $limit));
             while ($i < $min)
             {
             	$obj = $db->fetch_object($result);
                 $member = new Adherent($this->db);
-                if($member->fetch($obj->rowid)) {
+                if ($member->fetch($obj->rowid)) {
                     $obj_ret[] = $this->_cleanObjectDatas($member);
                 }
                 $i++;
@@ -150,7 +150,7 @@ class Members extends DolibarrApi
         else {
             throw new RestException(503, 'Error when retrieve member list : '.$db->lasterror());
         }
-        if( ! count($obj_ret)) {
+        if (!count($obj_ret)) {
             throw new RestException(404, 'No member found');
         }
 
@@ -165,14 +165,14 @@ class Members extends DolibarrApi
      */
     public function post($request_data = null)
     {
-        if(! DolibarrApiAccess::$user->rights->adherent->creer) {
+        if (!DolibarrApiAccess::$user->rights->adherent->creer) {
             throw new RestException(401);
         }
         // Check mandatory fields
         $result = $this->_validate($request_data);
 
         $member = new Adherent($this->db);
-        foreach($request_data as $field => $value) {
+        foreach ($request_data as $field => $value) {
             $member->$field = $value;
         }
         if ($member->create(DolibarrApiAccess::$user) < 0) {
@@ -190,21 +190,21 @@ class Members extends DolibarrApi
      */
     public function put($id, $request_data = null)
     {
-        if(! DolibarrApiAccess::$user->rights->adherent->creer) {
+        if (!DolibarrApiAccess::$user->rights->adherent->creer) {
             throw new RestException(401);
         }
 
         $member = new Adherent($this->db);
         $result = $member->fetch($id);
-        if( ! $result ) {
+        if (!$result) {
             throw new RestException(404, 'member not found');
         }
 
-        if( ! DolibarrApi::_checkAccessToResource('member', $member->id)) {
+        if (!DolibarrApi::_checkAccessToResource('member', $member->id)) {
             throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
         }
 
-        foreach($request_data as $field => $value) {
+        foreach ($request_data as $field => $value) {
             if ($field == 'id') continue;
             // Process the status separately because it must be updated using
             // the validate() and resiliate() methods of the class Adherent.
@@ -245,20 +245,20 @@ class Members extends DolibarrApi
      */
     public function delete($id)
     {
-        if(! DolibarrApiAccess::$user->rights->adherent->supprimer) {
+        if (!DolibarrApiAccess::$user->rights->adherent->supprimer) {
             throw new RestException(401);
         }
         $member = new Adherent($this->db);
         $result = $member->fetch($id);
-        if( ! $result ) {
+        if (!$result) {
             throw new RestException(404, 'member not found');
         }
 
-        if( ! DolibarrApi::_checkAccessToResource('member', $member->id)) {
+        if (!DolibarrApi::_checkAccessToResource('member', $member->id)) {
             throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
         }
 
-        if (! $member->delete($member->id, DolibarrApiAccess::$user)) {
+        if (!$member->delete($member->id, DolibarrApiAccess::$user)) {
             throw new RestException(401, 'error when deleting member');
         }
 
@@ -334,13 +334,13 @@ class Members extends DolibarrApi
     {
         $obj_ret = array();
 
-        if(! DolibarrApiAccess::$user->rights->adherent->cotisation->lire) {
+        if (!DolibarrApiAccess::$user->rights->adherent->cotisation->lire) {
             throw new RestException(401);
         }
 
         $member = new Adherent($this->db);
         $result = $member->fetch($id);
-        if( ! $result ) {
+        if (!$result) {
             throw new RestException(404, 'member not found');
         }
 
@@ -365,13 +365,13 @@ class Members extends DolibarrApi
      */
     public function createSubscription($id, $start_date, $end_date, $amount, $label = '')
     {
-        if(! DolibarrApiAccess::$user->rights->adherent->cotisation->creer) {
+        if (!DolibarrApiAccess::$user->rights->adherent->cotisation->creer) {
             throw new RestException(401);
         }
 
         $member = new Adherent($this->db);
         $result = $member->fetch($id);
-        if( ! $result ) {
+        if (!$result) {
             throw new RestException(404, 'member not found');
         }
 
@@ -393,7 +393,7 @@ class Members extends DolibarrApi
      */
 	public function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0)
 	{
-		if (! DolibarrApiAccess::$user->rights->categorie->lire) {
+		if (!DolibarrApiAccess::$user->rights->categorie->lire) {
 			throw new RestException(401);
 		}
 

+ 24 - 24
htdocs/adherents/class/api_memberstypes.class.php

@@ -55,17 +55,17 @@ class MembersTypes extends DolibarrApi
      */
     public function get($id)
     {
-        if(! DolibarrApiAccess::$user->rights->adherent->lire) {
+        if (!DolibarrApiAccess::$user->rights->adherent->lire) {
             throw new RestException(401);
         }
 
         $membertype = new AdherentType($this->db);
         $result = $membertype->fetch($id);
-        if( ! $result ) {
+        if (!$result) {
             throw new RestException(404, 'member type not found');
         }
 
-        if( ! DolibarrApi::_checkAccessToResource('member', $membertype->id, 'adherent_type')) {
+        if (!DolibarrApi::_checkAccessToResource('member', $membertype->id, 'adherent_type')) {
             throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
         }
 
@@ -92,40 +92,40 @@ class MembersTypes extends DolibarrApi
 
         $obj_ret = array();
 
-        if(! DolibarrApiAccess::$user->rights->adherent->lire) {
+        if (!DolibarrApiAccess::$user->rights->adherent->lire) {
             throw new RestException(401);
         }
 
         $sql = "SELECT t.rowid";
-        $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t";
-        $sql.= ' WHERE t.entity IN ('.getEntity('member_type').')';
+        $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as t";
+        $sql .= ' WHERE t.entity IN ('.getEntity('member_type').')';
 
         // Add sql filters
         if ($sqlfilters)
         {
-            if (! DolibarrApi::_checkFilters($sqlfilters))
+            if (!DolibarrApi::_checkFilters($sqlfilters))
             {
                 throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
             }
-	        $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
-            $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
+	        $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
+            $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
         }
 
-        $sql.= $db->order($sortfield, $sortorder);
-        if ($limit)    {
+        $sql .= $db->order($sortfield, $sortorder);
+        if ($limit) {
             if ($page < 0)
             {
                 $page = 0;
             }
             $offset = $limit * $page;
 
-            $sql.= $db->plimit($limit + 1, $offset);
+            $sql .= $db->plimit($limit + 1, $offset);
         }
 
         $result = $db->query($sql);
         if ($result)
         {
-            $i=0;
+            $i = 0;
             $num = $db->num_rows($result);
             $min = min($num, ($limit <= 0 ? $num : $limit));
             while ($i < $min)
@@ -141,7 +141,7 @@ class MembersTypes extends DolibarrApi
         else {
             throw new RestException(503, 'Error when retrieve member type list : '.$db->lasterror());
         }
-        if ( ! count($obj_ret)) {
+        if (!count($obj_ret)) {
             throw new RestException(404, 'No member type found');
         }
 
@@ -156,14 +156,14 @@ class MembersTypes extends DolibarrApi
      */
     public function post($request_data = null)
     {
-        if (! DolibarrApiAccess::$user->rights->adherent->configurer) {
+        if (!DolibarrApiAccess::$user->rights->adherent->configurer) {
             throw new RestException(401);
         }
         // Check mandatory fields
         $result = $this->_validate($request_data);
 
         $membertype = new AdherentType($this->db);
-        foreach($request_data as $field => $value) {
+        foreach ($request_data as $field => $value) {
             $membertype->$field = $value;
         }
         if ($membertype->create(DolibarrApiAccess::$user) < 0) {
@@ -181,21 +181,21 @@ class MembersTypes extends DolibarrApi
      */
     public function put($id, $request_data = null)
     {
-        if (! DolibarrApiAccess::$user->rights->adherent->configurer) {
+        if (!DolibarrApiAccess::$user->rights->adherent->configurer) {
             throw new RestException(401);
         }
 
         $membertype = new AdherentType($this->db);
         $result = $membertype->fetch($id);
-        if( ! $result ) {
+        if (!$result) {
             throw new RestException(404, 'member type not found');
         }
 
-        if( ! DolibarrApi::_checkAccessToResource('member', $membertype->id, 'adherent_type')) {
+        if (!DolibarrApi::_checkAccessToResource('member', $membertype->id, 'adherent_type')) {
             throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
         }
 
-        foreach($request_data as $field => $value) {
+        foreach ($request_data as $field => $value) {
             if ($field == 'id') continue;
             // Process the status separately because it must be updated using
             // the validate() and resiliate() methods of the class AdherentType.
@@ -222,20 +222,20 @@ class MembersTypes extends DolibarrApi
      */
     public function delete($id)
     {
-        if (! DolibarrApiAccess::$user->rights->adherent->configurer) {
+        if (!DolibarrApiAccess::$user->rights->adherent->configurer) {
             throw new RestException(401);
         }
         $membertype = new AdherentType($this->db);
         $result = $membertype->fetch($id);
-        if( ! $result ) {
+        if (!$result) {
             throw new RestException(404, 'member type not found');
         }
 
-        if ( ! DolibarrApi::_checkAccessToResource('member', $membertype->id, 'adherent_type')) {
+        if (!DolibarrApi::_checkAccessToResource('member', $membertype->id, 'adherent_type')) {
             throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
         }
 
-        if (! $membertype->delete()) {
+        if (!$membertype->delete()) {
             throw new RestException(401, 'error when deleting member type');
         }
 

+ 22 - 22
htdocs/adherents/class/api_subscriptions.class.php

@@ -58,13 +58,13 @@ class Subscriptions extends DolibarrApi
      */
     public function get($id)
     {
-        if(! DolibarrApiAccess::$user->rights->adherent->cotisation->lire) {
+        if (!DolibarrApiAccess::$user->rights->adherent->cotisation->lire) {
             throw new RestException(401);
         }
 
         $subscription = new Subscription($this->db);
         $result = $subscription->fetch($id);
-        if( ! $result ) {
+        if (!$result) {
             throw new RestException(404, 'Subscription not found');
         }
 
@@ -91,45 +91,45 @@ class Subscriptions extends DolibarrApi
 
         $obj_ret = array();
 
-        if(! DolibarrApiAccess::$user->rights->adherent->cotisation->lire) {
+        if (!DolibarrApiAccess::$user->rights->adherent->cotisation->lire) {
             throw new RestException(401);
         }
 
         $sql = "SELECT rowid";
-        $sql.= " FROM ".MAIN_DB_PREFIX."subscription as t";
-        $sql.= ' WHERE 1 = 1';
+        $sql .= " FROM ".MAIN_DB_PREFIX."subscription as t";
+        $sql .= ' WHERE 1 = 1';
         // Add sql filters
         if ($sqlfilters)
         {
-            if (! DolibarrApi::_checkFilters($sqlfilters))
+            if (!DolibarrApi::_checkFilters($sqlfilters))
             {
                 throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
             }
-	        $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
-            $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
+	        $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
+            $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
         }
 
-        $sql.= $db->order($sortfield, $sortorder);
-        if ($limit)    {
+        $sql .= $db->order($sortfield, $sortorder);
+        if ($limit) {
             if ($page < 0)
             {
                 $page = 0;
             }
             $offset = $limit * $page;
 
-            $sql.= $db->plimit($limit + 1, $offset);
+            $sql .= $db->plimit($limit + 1, $offset);
         }
 
         $result = $db->query($sql);
         if ($result)
         {
-            $i=0;
+            $i = 0;
             $num = $db->num_rows($result);
             while ($i < min($limit, $num))
             {
                 $obj = $db->fetch_object($result);
                 $subscription = new Subscription($this->db);
-                if($subscription->fetch($obj->rowid)) {
+                if ($subscription->fetch($obj->rowid)) {
                     $obj_ret[] = $this->_cleanObjectDatas($subscription);
                 }
                 $i++;
@@ -138,7 +138,7 @@ class Subscriptions extends DolibarrApi
         else {
             throw new RestException(503, 'Error when retrieve subscription list : '.$db->lasterror());
         }
-        if( ! count($obj_ret)) {
+        if (!count($obj_ret)) {
             throw new RestException(404, 'No Subscription found');
         }
 
@@ -153,14 +153,14 @@ class Subscriptions extends DolibarrApi
      */
     public function post($request_data = null)
     {
-        if(! DolibarrApiAccess::$user->rights->adherent->cotisation->creer) {
+        if (!DolibarrApiAccess::$user->rights->adherent->cotisation->creer) {
             throw new RestException(401);
         }
         // Check mandatory fields
         $result = $this->_validate($request_data);
 
         $subscription = new Subscription($this->db);
-        foreach($request_data as $field => $value) {
+        foreach ($request_data as $field => $value) {
             $subscription->$field = $value;
         }
         if ($subscription->create(DolibarrApiAccess::$user) < 0) {
@@ -178,17 +178,17 @@ class Subscriptions extends DolibarrApi
      */
     public function put($id, $request_data = null)
     {
-        if(! DolibarrApiAccess::$user->rights->adherent->creer) {
+        if (!DolibarrApiAccess::$user->rights->adherent->creer) {
             throw new RestException(401);
         }
 
         $subscription = new Subscription($this->db);
         $result = $subscription->fetch($id);
-        if( ! $result ) {
+        if (!$result) {
             throw new RestException(404, 'Subscription not found');
         }
 
-        foreach($request_data as $field => $value) {
+        foreach ($request_data as $field => $value) {
             if ($field == 'id') continue;
             $subscription->$field = $value;
         }
@@ -212,16 +212,16 @@ class Subscriptions extends DolibarrApi
     public function delete($id)
     {
         // The right to delete a subscription comes with the right to create one.
-        if(! DolibarrApiAccess::$user->rights->adherent->cotisation->creer) {
+        if (!DolibarrApiAccess::$user->rights->adherent->cotisation->creer) {
             throw new RestException(401);
         }
         $subscription = new Subscription($this->db);
         $result = $subscription->fetch($id);
-        if( ! $result ) {
+        if (!$result) {
             throw new RestException(404, 'Subscription not found');
         }
 
-        if (! $subscription->delete(DolibarrApiAccess::$user)) {
+        if (!$subscription->delete(DolibarrApiAccess::$user)) {
             throw new RestException(401, 'error when deleting subscription');
         }
 

+ 61 - 61
htdocs/adherents/class/subscription.class.php

@@ -35,12 +35,12 @@ class Subscription extends CommonObject
     /**
      * @var string ID to identify managed object
      */
-    public $element='subscription';
+    public $element = 'subscription';
 
     /**
      * @var string Name of table without prefix where object is stored
      */
-    public $table_element='subscription';
+    public $table_element = 'subscription';
 
     /**
      * @var int  Does myobject support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by fk_soc, 'field@table'=Test with link by field@table
@@ -50,7 +50,7 @@ class Subscription extends CommonObject
     /**
      * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
      */
-    public $picto='payment';
+    public $picto = 'payment';
 
     /**
      * Date creation record (datec)
@@ -93,7 +93,7 @@ class Subscription extends CommonObject
      */
     public $fk_bank;
 
-    public $fields=array(
+    public $fields = array(
     	'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10),
     	'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>15),
     	'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>20),
@@ -133,12 +133,12 @@ class Subscription extends CommonObject
 
         $error = 0;
 
-        $now=dol_now();
+        $now = dol_now();
 
         // Check parameters
         if ($this->datef <= $this->dateh)
         {
-            $this->error=$langs->trans("ErrorBadValueForDate");
+            $this->error = $langs->trans("ErrorBadValueForDate");
             return -1;
         }
         if (empty($this->datec)) $this->datec = $now;
@@ -149,37 +149,37 @@ class Subscription extends CommonObject
         $sql = "INSERT INTO ".MAIN_DB_PREFIX."subscription (fk_adherent, fk_type, datec, dateadh, datef, subscription, note)";
 
         require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
-        $member=new Adherent($this->db);
-        $result=$member->fetch($this->fk_adherent);
+        $member = new Adherent($this->db);
+        $result = $member->fetch($this->fk_adherent);
 
         if ($this->fk_type == null) {	// If type not defined, we use the type of member
-            $type=$member->typeid;
+            $type = $member->typeid;
         } else {
-            $type=$this->fk_type;
+            $type = $this->fk_type;
         }
-        $sql.= " VALUES (".$this->fk_adherent.", '".$type."', '".$this->db->idate($now)."',";
-        $sql.= " '".$this->db->idate($this->dateh)."',";
-        $sql.= " '".$this->db->idate($this->datef)."',";
-        $sql.= " ".$this->amount.",";
-        $sql.= " '".$this->db->escape($this->note_public?$this->note_public:$this->note)."')";
+        $sql .= " VALUES (".$this->fk_adherent.", '".$type."', '".$this->db->idate($now)."',";
+        $sql .= " '".$this->db->idate($this->dateh)."',";
+        $sql .= " '".$this->db->idate($this->datef)."',";
+        $sql .= " ".$this->amount.",";
+        $sql .= " '".$this->db->escape($this->note_public ? $this->note_public : $this->note)."')";
 
         $resql = $this->db->query($sql);
-        if (! $resql) {
+        if (!$resql) {
             $error++;
             $this->errors[] = $this->db->lasterror();
         }
 
-        if (! $error)
+        if (!$error)
         {
-            $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element);
+            $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
             $this->fk_type = $type;
         }
 
-        if (! $error && ! $notrigger)
+        if (!$error && !$notrigger)
         {
         	$this->context = array('member'=>$member);
         	// Call triggers
-            $result=$this->call_trigger('MEMBER_SUBSCRIPTION_CREATE', $user);
+            $result = $this->call_trigger('MEMBER_SUBSCRIPTION_CREATE', $user);
             if ($result < 0) { $error++; }
             // End call triggers
         }
@@ -203,16 +203,16 @@ class Subscription extends CommonObject
      */
     public function fetch($rowid)
     {
-        $sql ="SELECT rowid, fk_type, fk_adherent, datec,";
-        $sql.=" tms,";
-        $sql.=" dateadh as dateh,";
-        $sql.=" datef,";
-        $sql.=" subscription, note, fk_bank";
-        $sql.=" FROM ".MAIN_DB_PREFIX."subscription";
-        $sql.="	WHERE rowid=".$rowid;
+        $sql = "SELECT rowid, fk_type, fk_adherent, datec,";
+        $sql .= " tms,";
+        $sql .= " dateadh as dateh,";
+        $sql .= " datef,";
+        $sql .= " subscription, note, fk_bank";
+        $sql .= " FROM ".MAIN_DB_PREFIX."subscription";
+        $sql .= "	WHERE rowid=".$rowid;
 
         dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
-        $resql=$this->db->query($sql);
+        $resql = $this->db->query($sql);
         if ($resql)
         {
             if ($this->db->num_rows($resql))
@@ -240,7 +240,7 @@ class Subscription extends CommonObject
         }
         else
         {
-            $this->error=$this->db->lasterror();
+            $this->error = $this->db->lasterror();
             return -1;
         }
     }
@@ -275,14 +275,14 @@ class Subscription extends CommonObject
         if ($resql)
         {
             require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
-            $member=new Adherent($this->db);
-            $result=$member->fetch($this->fk_adherent);
-            $result=$member->update_end_date($user);
+            $member = new Adherent($this->db);
+            $result = $member->fetch($this->fk_adherent);
+            $result = $member->update_end_date($user);
 
-            if (! $error && ! $notrigger) {
+            if (!$error && !$notrigger) {
             	$this->context = array('member'=>$member);
             	// Call triggers
-                $result=$this->call_trigger('MEMBER_SUBSCRIPTION_MODIFY', $user);
+                $result = $this->call_trigger('MEMBER_SUBSCRIPTION_MODIFY', $user);
                 if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail
                 // End call triggers
             }
@@ -290,7 +290,7 @@ class Subscription extends CommonObject
         else
         {
             $error++;
-            $this->error=$this->db->lasterror();
+            $this->error = $this->db->lasterror();
         }
 
         // Commit or rollback
@@ -318,39 +318,39 @@ class Subscription extends CommonObject
         if ($this->fk_bank > 0)
         {
             require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
-            $accountline=new AccountLine($this->db);
-            $result=$accountline->fetch($this->fk_bank);
+            $accountline = new AccountLine($this->db);
+            $result = $accountline->fetch($this->fk_bank);
         }
 
         $this->db->begin();
 
-        if (! $error) {
-            if (! $notrigger) {
+        if (!$error) {
+            if (!$notrigger) {
                 // Call triggers
-                $result=$this->call_trigger('MEMBER_SUBSCRIPTION_DELETE', $user);
+                $result = $this->call_trigger('MEMBER_SUBSCRIPTION_DELETE', $user);
                 if ($result < 0) { $error++; } // Do also here what you must do to rollback action if trigger fail
                 // End call triggers
             }
         }
 
-        if (! $error)
+        if (!$error)
         {
             $sql = "DELETE FROM ".MAIN_DB_PREFIX."subscription WHERE rowid = ".$this->id;
             dol_syslog(get_class($this)."::delete", LOG_DEBUG);
-            $resql=$this->db->query($sql);
+            $resql = $this->db->query($sql);
             if ($resql)
             {
-                $num=$this->db->affected_rows($resql);
+                $num = $this->db->affected_rows($resql);
                 if ($num)
                 {
                     require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
-                    $member=new Adherent($this->db);
-                    $result=$member->fetch($this->fk_adherent);
-                    $result=$member->update_end_date($user);
+                    $member = new Adherent($this->db);
+                    $result = $member->fetch($this->fk_adherent);
+                    $result = $member->update_end_date($user);
 
                     if ($this->fk_bank > 0 && is_object($accountline) && $accountline->id > 0)	// If we found bank account line (this means this->fk_bank defined)
                     {
-                        $result=$accountline->delete($user);		// Return false if refused because line is conciliated
+                        $result = $accountline->delete($user); // Return false if refused because line is conciliated
                         if ($result > 0)
                         {
                             $this->db->commit();
@@ -358,7 +358,7 @@ class Subscription extends CommonObject
                         }
                         else
                         {
-                            $this->error=$accountline->error;
+                            $this->error = $accountline->error;
                             $this->db->rollback();
                             return -1;
                         }
@@ -378,7 +378,7 @@ class Subscription extends CommonObject
             else
             {
                 $error++;
-                $this->error=$this->db->lasterror();
+                $this->error = $this->db->lasterror();
             }
         }
 
@@ -407,29 +407,29 @@ class Subscription extends CommonObject
     {
         global $langs;
 
-        $result='';
+        $result = '';
 
         $langs->load("members");
-        $label=$langs->trans("ShowSubscription").': '.$this->ref;
+        $label = $langs->trans("ShowSubscription").': '.$this->ref;
 
         $url = DOL_URL_ROOT.'/adherents/subscription/card.php?rowid='.$this->id;
 
         if ($option != 'nolink')
         {
             // Add param to save lastsearch_values or not
-            $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
-            if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1;
-            if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
+            $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
+            if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
+            if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
         }
 
         $linkstart = '<a href="'.$url.'" class="classfortooltip" title="'.dol_escape_htmltag($label, 1).'">';
         $linkend = '</a>';
 
-        $picto='payment';
+        $picto = 'payment';
 
         $result .= $linkstart;
-        if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
-        if ($withpicto != 2) $result.= $this->ref;
+        if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
+        if ($withpicto != 2) $result .= $this->ref;
         $result .= $linkend;
 
         return $result;
@@ -471,11 +471,11 @@ class Subscription extends CommonObject
     public function info($id)
     {
         $sql = 'SELECT c.rowid, c.datec,';
-        $sql.= ' c.tms as datem';
-        $sql.= ' FROM '.MAIN_DB_PREFIX.'subscription as c';
-        $sql.= ' WHERE c.rowid = '.$id;
+        $sql .= ' c.tms as datem';
+        $sql .= ' FROM '.MAIN_DB_PREFIX.'subscription as c';
+        $sql .= ' WHERE c.rowid = '.$id;
 
-        $result=$this->db->query($sql);
+        $result = $this->db->query($sql);
         if ($result)
         {
             if ($this->db->num_rows($result))

+ 23 - 23
htdocs/adherents/document.php

@@ -34,45 +34,45 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
 
 // Load translation files required by the page
-$langs->loadLangs(array("companies","members","other"));
+$langs->loadLangs(array("companies", "members", "other"));
 
 
-$id=GETPOST('id', 'int');
-$action=GETPOST('action', 'alpha');
-$confirm=GETPOST('confirm', 'alpha');
+$id = GETPOST('id', 'int');
+$action = GETPOST('action', 'alpha');
+$confirm = GETPOST('confirm', 'alpha');
 
 // Security check
-$result=restrictedArea($user, 'adherent', $id);
+$result = restrictedArea($user, 'adherent', $id);
 
 // Get parameters
 $sortfield = GETPOST("sortfield", 'alpha');
 $sortorder = GETPOST("sortorder", 'alpha');
 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
 if (empty($page) || $page == -1) { $page = 0; }     // If $page is not defined, or '' or -1
-$offset = $conf->liste_limit * $page ;
+$offset = $conf->liste_limit * $page;
 $pageprev = $page - 1;
 $pagenext = $page + 1;
-if (! $sortorder) $sortorder="ASC";
-if (! $sortfield) $sortfield="name";
+if (!$sortorder) $sortorder = "ASC";
+if (!$sortfield) $sortfield = "name";
 
 
 $form = new Form($db);
-$object=new Adherent($db);
-$membert=new AdherentType($db);
-$result=$object->fetch($id);
+$object = new Adherent($db);
+$membert = new AdherentType($db);
+$result = $object->fetch($id);
 if ($result < 0)
 {
 	dol_print_error($db);
 	exit;
 }
-$upload_dir = $conf->adherent->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'member');
+$upload_dir = $conf->adherent->dir_output."/".get_exdir(0, 0, 0, 1, $object, 'member');
 
 
 /*
  * Actions
  */
 
-include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php';
+include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
 
 
 /*
@@ -81,24 +81,24 @@ include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php';
 
 $form = new Form($db);
 
-$title=$langs->trans("Member") . " - " . $langs->trans("Documents");
-$helpurl="EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros";
+$title = $langs->trans("Member")." - ".$langs->trans("Documents");
+$helpurl = "EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros";
 llxHeader("", $title, $helpurl);
 
 if ($id > 0)
 {
-    $result=$membert->fetch($object->typeid);
+    $result = $membert->fetch($object->typeid);
 	if ($result > 0)
 	{
 		// Build file list
-		$filearray=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC), 1);
-		$totalsize=0;
-		foreach($filearray as $key => $file)
+		$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
+		$totalsize = 0;
+		foreach ($filearray as $key => $file)
 		{
-			$totalsize+=$file['size'];
+			$totalsize += $file['size'];
 		}
 
-	    if (! empty($conf->notification->enabled))
+	    if (!empty($conf->notification->enabled))
 			$langs->load("mails");
 
 		$head = member_prepare_head($object);
@@ -154,8 +154,8 @@ if ($id > 0)
 		$modulepart = 'member';
 		$permission = $user->rights->adherent->creer;
 		$permtoedit = $user->rights->adherent->creer;
-		$param = '&id=' . $object->id;
-		include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
+		$param = '&id='.$object->id;
+		include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
 		print "<br><br>";
 	}
 	else

+ 10 - 10
htdocs/adherents/htpasswd.php

@@ -27,7 +27,7 @@ require '../main.inc.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
 
 // Security check
-if (! $user->rights->adherent->export) accessforbidden();
+if (!$user->rights->adherent->export) accessforbidden();
 
 
 /*
@@ -36,30 +36,30 @@ if (! $user->rights->adherent->export) accessforbidden();
 
 llxHeader();
 
-$now=dol_now();
+$now = dol_now();
 
-if (empty($sortorder)) {  $sortorder="ASC"; }
-if (empty($sortfield)) {  $sortfield="d.login"; }
-if (! isset($statut))
+if (empty($sortorder)) {  $sortorder = "ASC"; }
+if (empty($sortfield)) {  $sortfield = "d.login"; }
+if (!isset($statut))
 {
 	$statut = 1;
 }
 
-if (! isset($cotis))
+if (!isset($cotis))
 {
 	// by default, members must be up to date of subscription
-	$cotis=1;
+	$cotis = 1;
 }
 
 
 $sql = "SELECT d.login, d.pass, d.datefin";
 $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d ";
 $sql .= " WHERE d.statut = ".$statut;
-if ($cotis==1)
+if ($cotis == 1)
 {
 	$sql .= " AND datefin > '".$db->idate($now)."'";
 }
-$sql.= $db->order($sortfield, $sortorder);
+$sql .= $db->order($sortfield, $sortorder);
 //$sql.=$db->plimit($conf->liste_limit, $offset);
 
 $resql = $db->query($sql);
@@ -74,7 +74,7 @@ if ($resql)
 	while ($i < $num)
 	{
 		$objp = $db->fetch_object($result);
-		$htpass=crypt($objp->pass, makesalt());
+		$htpass = crypt($objp->pass, makesalt());
 		print $objp->login.":".$htpass."<br>\n";
 		$i++;
 	}

+ 46 - 46
htdocs/adherents/index.php

@@ -48,28 +48,28 @@ $result = restrictedArea($user, 'adherent');
 
 llxHeader('', $langs->trans("Members"), 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros');
 
-$staticmember=new Adherent($db);
-$statictype=new AdherentType($db);
-$subscriptionstatic=new Subscription($db);
+$staticmember = new Adherent($db);
+$statictype = new AdherentType($db);
+$subscriptionstatic = new Subscription($db);
 
 print load_fiche_titre($langs->trans("MembersArea"), '', 'members');
 
-$Adherents=array();
-$AdherentsAValider=array();
-$MemberUpToDate=array();
-$AdherentsResilies=array();
+$Adherents = array();
+$AdherentsAValider = array();
+$MemberUpToDate = array();
+$AdherentsResilies = array();
 
-$AdherentType=array();
+$AdherentType = array();
 
 // Type of membership
 $sql = "SELECT t.rowid, t.libelle as label, t.subscription,";
-$sql.= " d.statut, count(d.rowid) as somme";
-$sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t";
-$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d";
-$sql.= " ON t.rowid = d.fk_adherent_type";
-$sql.= " AND d.entity IN (".getEntity('adherent').")";
-$sql.= " WHERE t.entity IN (".getEntity('member_type').")";
-$sql.= " GROUP BY t.rowid, t.libelle, t.subscription, d.statut";
+$sql .= " d.statut, count(d.rowid) as somme";
+$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as t";
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d";
+$sql .= " ON t.rowid = d.fk_adherent_type";
+$sql .= " AND d.entity IN (".getEntity('adherent').")";
+$sql .= " WHERE t.entity IN (".getEntity('member_type').")";
+$sql .= " GROUP BY t.rowid, t.libelle, t.subscription, d.statut";
 
 dol_syslog("index.php::select nb of members per type", LOG_DEBUG);
 $result = $db->query($sql);
@@ -81,32 +81,32 @@ if ($result)
 	{
 		$objp = $db->fetch_object($result);
 
-		$adhtype=new AdherentType($db);
-		$adhtype->id=$objp->rowid;
-		$adhtype->subscription=$objp->subscription;
-		$adhtype->label=$objp->label;
-		$AdherentType[$objp->rowid]=$adhtype;
+		$adhtype = new AdherentType($db);
+		$adhtype->id = $objp->rowid;
+		$adhtype->subscription = $objp->subscription;
+		$adhtype->label = $objp->label;
+		$AdherentType[$objp->rowid] = $adhtype;
 
-		if ($objp->statut == -1) { $MemberToValidate[$objp->rowid]=$objp->somme; }
-		if ($objp->statut == 1)  { $MembersValidated[$objp->rowid]=$objp->somme; }
-		if ($objp->statut == 0)  { $MembersResiliated[$objp->rowid]=$objp->somme; }
+		if ($objp->statut == -1) { $MemberToValidate[$objp->rowid] = $objp->somme; }
+		if ($objp->statut == 1) { $MembersValidated[$objp->rowid] = $objp->somme; }
+		if ($objp->statut == 0) { $MembersResiliated[$objp->rowid] = $objp->somme; }
 
 		$i++;
 	}
 	$db->free($result);
 }
 
-$now=dol_now();
+$now = dol_now();
 
 // Members up to date list
 // current rule: uptodate = the end date is in future whatever is type
 // old rule: uptodate = if type does not need payment, that end date is null, if type need payment that end date is in future)
 $sql = "SELECT count(*) as somme , d.fk_adherent_type";
-$sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t";
-$sql.= " WHERE d.entity IN (".getEntity('adherent').")";
-$sql.= " AND d.statut = 1 AND (d.datefin >= '".$db->idate($now)."' OR t.subscription = 0)";
-$sql.= " AND t.rowid = d.fk_adherent_type";
-$sql.= " GROUP BY d.fk_adherent_type";
+$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t";
+$sql .= " WHERE d.entity IN (".getEntity('adherent').")";
+$sql .= " AND d.statut = 1 AND (d.datefin >= '".$db->idate($now)."' OR t.subscription = 0)";
+$sql .= " AND t.rowid = d.fk_adherent_type";
+$sql .= " GROUP BY d.fk_adherent_type";
 
 dol_syslog("index.php::select nb of uptodate members by type", LOG_DEBUG);
 $result = $db->query($sql);
@@ -220,15 +220,15 @@ if ($conf->use_javascript_ajax)
 print '<br>';
 
 // List of subscription by year
-$Total=array();
-$Number=array();
-$tot=0;
-$numb=0;
+$Total = array();
+$Number = array();
+$tot = 0;
+$numb = 0;
 
 $sql = "SELECT c.subscription, c.dateadh as dateh";
-$sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."subscription as c";
-$sql.= " WHERE d.entity IN (".getEntity('adherent').")";
-$sql.= " AND d.rowid = c.fk_adherent";
+$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."subscription as c";
+$sql .= " WHERE d.entity IN (".getEntity('adherent').")";
+$sql .= " AND d.rowid = c.fk_adherent";
 
 
 $result = $db->query($sql);
@@ -323,26 +323,26 @@ if ($resql)
 		{
 			$obj = $db->fetch_object($resql);
 			print '<tr class="oddeven">';
-			$staticmember->id=$obj->rowid;
-			$staticmember->lastname=$obj->lastname;
-			$staticmember->firstname=$obj->firstname;
-			if (! empty($obj->fk_soc))
+			$staticmember->id = $obj->rowid;
+			$staticmember->lastname = $obj->lastname;
+			$staticmember->firstname = $obj->firstname;
+			if (!empty($obj->fk_soc))
 			{
 				$staticmember->fk_soc = $obj->fk_soc;
 				$staticmember->fetch_thirdparty();
-				$staticmember->name=$staticmember->thirdparty->name;
+				$staticmember->name = $staticmember->thirdparty->name;
 			}
 			else
 			{
-				$staticmember->name=$obj->company;
+				$staticmember->name = $obj->company;
 			}
-			$staticmember->ref=$staticmember->getFullName($langs);
-			$statictype->id=$obj->typeid;
-			$statictype->label=$obj->label;
+			$staticmember->ref = $staticmember->getFullName($langs);
+			$statictype->id = $obj->typeid;
+			$statictype->label = $obj->label;
 			print '<td>'.$staticmember->getNomUrl(1, 32).'</td>';
 			print '<td>'.$statictype->getNomUrl(1, 32).'</td>';
 			print '<td>'.dol_print_date($db->jdate($obj->datem), 'dayhour').'</td>';
-			print '<td class="right">'.$staticmember->LibStatut($obj->statut, ($obj->subscription=='yes'?1:0), $db->jdate($obj->date_end_subscription), 3).'</td>';
+			print '<td class="right">'.$staticmember->LibStatut($obj->statut, ($obj->subscription == 'yes' ? 1 : 0), $db->jdate($obj->date_end_subscription), 3).'</td>';
 			print '</tr>';
 			$i++;
 		}

+ 20 - 20
htdocs/adherents/ldap.php

@@ -30,21 +30,21 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
 
 // Load translation files required by the page
-$langs->loadLangs(array("companies","members","ldap","admin"));
+$langs->loadLangs(array("companies", "members", "ldap", "admin"));
 
 $rowid = GETPOST('id', 'int');
 $action = GETPOST('action', 'aZ09');
 
 // Protection
-$socid=0;
+$socid = 0;
 if ($user->socid > 0)
 {
     $socid = $user->socid;
 }
 
 $object = new Adherent($db);
-$result=$object->fetch($rowid);
-if (! $result)
+$result = $object->fetch($rowid);
+if (!$result)
 {
 	dol_print_error($db, "Failed to get adherent: ".$object->error);
 	exit;
@@ -57,16 +57,16 @@ if (! $result)
 
 if ($action == 'dolibarr2ldap')
 {
-	$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);
-		$olddn=$dn;	// We can say that old dn = dn as we force synchro
+		$info = $object->_load_ldap_info();
+		$dn = $object->_load_ldap_dn($info);
+		$olddn = $dn; // We can say that old dn = dn as we force synchro
 
-		$result=$ldap->update($dn, $info, $user, $olddn);
+		$result = $ldap->update($dn, $info, $user, $olddn);
 	}
 
 	if ($result >= 0) {
@@ -104,7 +104,7 @@ print '<table class="border centpercent tableforfield">';
 print '<tr><td class="titlefield">'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.$object->login.'&nbsp;</td></tr>';
 
 // If there is a link to password not crypted, we show value in database here so we can compare because it is shown nowhere else
-if (! empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD))
+if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD))
 {
 	print '<tr><td>'.$langs->trans("LDAPFieldPasswordNotCrypted").'</td>';
 	print '<td class="valeur">'.$object->pass.'</td>';
@@ -142,14 +142,14 @@ dol_fiche_end();
 
 print '<div class="tabsAction">';
 
-if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && $conf->global->LDAP_MEMBER_ACTIVE != 'ldap2dolibarr')
+if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && $conf->global->LDAP_MEMBER_ACTIVE != 'ldap2dolibarr')
 {
 	print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=dolibarr2ldap">'.$langs->trans("ForceSynchronize").'</a></div>';
 }
 
 print "</div>\n";
 
-if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && $conf->global->LDAP_MEMBER_ACTIVE != 'ldap2dolibarr') print "<br>\n";
+if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && $conf->global->LDAP_MEMBER_ACTIVE != 'ldap2dolibarr') print "<br>\n";
 
 
 
@@ -164,12 +164,12 @@ print '<td>'.$langs->trans("Value").'</td>';
 print '</tr>';
 
 // Lecture LDAP
-$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, 1);
+	$info = $object->_load_ldap_info();
+	$dn = $object->_load_ldap_dn($info, 1);
 	$search = "(".$object->_load_ldap_dn($info, 2).")";
 
 	if (empty($dn))
@@ -184,15 +184,15 @@ if ($result > 0)
     	//print_r($records);
 
     	// Show tree
-    	if (((! is_numeric($records)) || $records != 0) && (! isset($records['count']) || $records['count'] > 0))
+    	if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0))
     	{
-    		if (! is_array($records))
+    		if (!is_array($records))
     		{
     			print '<tr class="oddeven"><td colspan="2"><font class="error">'.$langs->trans("ErrorFailedToReadLDAP").'</font></td></tr>';
     		}
     		else
     		{
-    			$result=show_ldap_content($records, 0, $records['count'], true);
+    			$result = show_ldap_content($records, 0, $records['count'], true);
     		}
     	}
     	else

+ 11 - 11
htdocs/adherents/note.php

@@ -29,23 +29,23 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
 
 // Load translation files required by the page
-$langs->loadLangs(array("companies","members","bills"));
+$langs->loadLangs(array("companies", "members", "bills"));
 
-$action=GETPOST('action', 'alpha');
-$id=GETPOST('id', 'int');
+$action = GETPOST('action', 'alpha');
+$id = GETPOST('id', 'int');
 
 // Security check
-$result=restrictedArea($user, 'adherent', $id);
+$result = restrictedArea($user, 'adherent', $id);
 
 $object = new Adherent($db);
-$result=$object->fetch($id);
+$result = $object->fetch($id);
 if ($result > 0)
 {
     $adht = new AdherentType($db);
-    $result=$adht->fetch($object->typeid);
+    $result = $adht->fetch($object->typeid);
 }
 
-$permissionnote=$user->rights->adherent->creer;  // Used by the include of actions_setnotes.inc.php
+$permissionnote = $user->rights->adherent->creer; // Used by the include of actions_setnotes.inc.php
 
 /*
  * Actions
@@ -58,8 +58,8 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include,
 /*
  * View
  */
-$title=$langs->trans("Member") . " - " . $langs->trans("Note");
-$helpurl="EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros";
+$title = $langs->trans("Member")." - ".$langs->trans("Note");
+$helpurl = "EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros";
 llxHeader("", $title, $helpurl);
 
 $form = new Form($db);
@@ -110,8 +110,8 @@ if ($id)
     print '</div>';
 
 
-    $cssclass='titlefield';
-    $permission = $user->rights->adherent->creer;  // Used by the include of notes.tpl.php
+    $cssclass = 'titlefield';
+    $permission = $user->rights->adherent->creer; // Used by the include of notes.tpl.php
     include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
 
 

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

@@ -29,7 +29,7 @@ $graphwidth = 700;
 $mapratio = 0.5;
 $graphheight = round($graphwidth * $mapratio);
 
-$mode=GETPOST('mode')?GETPOST('mode'):'';
+$mode = GETPOST('mode') ?GETPOST('mode') : '';
 
 
 // Security check
@@ -38,57 +38,57 @@ if ($user->socid > 0)
     $action = '';
     $socid = $user->socid;
 }
-$result=restrictedArea($user, 'adherent', '', '', 'cotisation');
+$result = restrictedArea($user, 'adherent', '', '', 'cotisation');
 
 $year = strftime("%Y", time());
-$startyear=$year-2;
-$endyear=$year;
+$startyear = $year - 2;
+$endyear = $year;
 
 // Load translation files required by the page
-$langs->loadLangs(array("companies","members"));
+$langs->loadLangs(array("companies", "members"));
 
 
 /*
  * View
  */
 
-$memberstatic=new Adherent($db);
+$memberstatic = new Adherent($db);
 
 llxHeader('', $langs->trans("MembersStatisticsByProperties"), '', '', 0, 0, array('https://www.google.com/jsapi'));
 
-$title=$langs->trans("MembersStatisticsByProperties");
+$title = $langs->trans("MembersStatisticsByProperties");
 
 print load_fiche_titre($title, '');
 
 dol_mkdir($dir);
 
-$tab='byproperties';
+$tab = 'byproperties';
 
 $data = array();
-$sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, d.morphy as code";
-$sql.=" FROM ".MAIN_DB_PREFIX."adherent as d";
-$sql.=" LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid";
-$sql.=" WHERE d.entity IN (".getEntity('adherent').")";
-$sql.=" AND d.statut = 1";
-$sql.=" GROUP BY d.morphy";
+$sql .= "SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, d.morphy as code";
+$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d";
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid";
+$sql .= " WHERE d.entity IN (".getEntity('adherent').")";
+$sql .= " AND d.statut = 1";
+$sql .= " GROUP BY d.morphy";
 
-$foundphy=$foundmor=0;
+$foundphy = $foundmor = 0;
 
 // Define $data array
 dol_syslog("Count member", LOG_DEBUG);
-$resql=$db->query($sql);
+$resql = $db->query($sql);
 if ($resql)
 {
-	$num=$db->num_rows($resql);
-	$i=0;
+	$num = $db->num_rows($resql);
+	$i = 0;
 	while ($i < $num)
 	{
-		$obj=$db->fetch_object($resql);
+		$obj = $db->fetch_object($resql);
 
 		if ($obj->code == 'phy') $foundphy++;
 		if ($obj->code == 'mor') $foundmor++;
 
-		$data[]=array('label'=>$obj->code, 'nb'=>$obj->nb, 'lastdate'=>$db->jdate($obj->lastdate), 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate));
+		$data[] = array('label'=>$obj->code, 'nb'=>$obj->nb, 'lastdate'=>$db->jdate($obj->lastdate), 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate));
 
 		$i++;
 	}
@@ -106,7 +106,7 @@ dol_fiche_head($head, 'statsbyproperties', $langs->trans("Statistics"), -1, 'use
 
 
 // Print title
-if (! count($data))
+if (!count($data))
 {
 	print $langs->trans("NoValidatedMemberYet").'<br>';
 	print '<br>';
@@ -125,8 +125,8 @@ print '<td class="center">'.$langs->trans("LastMemberDate").'</td>';
 print '<td class="center">'.$langs->trans("LatestSubscriptionDate").'</td>';
 print '</tr>';
 
-if (! $foundphy) $data[]=array('label'=>'phy','nb'=>'0','lastdate'=>'', 'lastsubscriptiondate'=>'');
-if (! $foundmor) $data[]=array('label'=>'mor','nb'=>'0','lastdate'=>'', 'lastsubscriptiondate'=>'');
+if (!$foundphy) $data[] = array('label'=>'phy', 'nb'=>'0', 'lastdate'=>'', 'lastsubscriptiondate'=>'');
+if (!$foundmor) $data[] = array('label'=>'mor', 'nb'=>'0', 'lastdate'=>'', 'lastsubscriptiondate'=>'');
 
 foreach ($data as $val)
 {

+ 81 - 81
htdocs/adherents/stats/geo.php

@@ -26,11 +26,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
 require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
 
-$graphwidth=DolGraph::getDefaultGraphSizeForStats('width', 700);
+$graphwidth = DolGraph::getDefaultGraphSizeForStats('width', 700);
 $mapratio = 0.5;
 $graphheight = round($graphwidth * $mapratio);
 
-$mode=GETPOST('mode')?GETPOST('mode'):'';
+$mode = GETPOST('mode') ?GETPOST('mode') : '';
 
 
 // Security check
@@ -39,28 +39,28 @@ if ($user->socid > 0)
     $action = '';
     $socid = $user->socid;
 }
-$result=restrictedArea($user, 'adherent', '', '', 'cotisation');
+$result = restrictedArea($user, 'adherent', '', '', 'cotisation');
 
 $year = strftime("%Y", time());
-$startyear=$year-2;
-$endyear=$year;
+$startyear = $year - 2;
+$endyear = $year;
 
 // Load translation files required by the page
-$langs->loadLangs(array("companies","members"));
+$langs->loadLangs(array("companies", "members"));
 
 
 /*
  * View
  */
 
-$arrayjs=array('https://www.google.com/jsapi');
-if (! empty($conf->dol_use_jmobile)) $arrayjs=array();
+$arrayjs = array('https://www.google.com/jsapi');
+if (!empty($conf->dol_use_jmobile)) $arrayjs = array();
 
-$title=$langs->trans("Statistics");
-if ($mode == 'memberbycountry') $title=$langs->trans("MembersStatisticsByCountries");
-if ($mode == 'memberbystate') $title=$langs->trans("MembersStatisticsByState");
-if ($mode == 'memberbytown') $title=$langs->trans("MembersStatisticsByTown");
-if ($mode == 'memberbyregion') $title=$langs->trans("MembersStatisticsByRegion");
+$title = $langs->trans("Statistics");
+if ($mode == 'memberbycountry') $title = $langs->trans("MembersStatisticsByCountries");
+if ($mode == 'memberbystate') $title = $langs->trans("MembersStatisticsByState");
+if ($mode == 'memberbytown') $title = $langs->trans("MembersStatisticsByTown");
+if ($mode == 'memberbyregion') $title = $langs->trans("MembersStatisticsByRegion");
 
 llxHeader('', $title, '', '', 0, 0, $arrayjs);
 
@@ -73,92 +73,92 @@ if ($mode)
     // Define sql
     if ($mode == 'memberbycountry')
     {
-        $label=$langs->trans("Country");
-        $tab='statscountry';
+        $label = $langs->trans("Country");
+        $tab = 'statscountry';
 
         $data = array();
-        $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, c.code, c.label";
-        $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d";
-        $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_country as c on d.country = c.rowid";
-        $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid";
-        $sql.=" WHERE d.entity IN (".getEntity('adherent').")";
-        $sql.=" AND d.statut = 1";
-        $sql.=" GROUP BY c.label, c.code";
+        $sql .= "SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, c.code, c.label";
+        $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d";
+        $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c on d.country = c.rowid";
+        $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid";
+        $sql .= " WHERE d.entity IN (".getEntity('adherent').")";
+        $sql .= " AND d.statut = 1";
+        $sql .= " GROUP BY c.label, c.code";
         //print $sql;
     }
 
 	if ($mode == 'memberbystate')
     {
-        $label=$langs->trans("Country");
-        $label2=$langs->trans("State");
-        $tab='statsstate';
+        $label = $langs->trans("Country");
+        $label2 = $langs->trans("State");
+        $tab = 'statsstate';
 
         $data = array();
-        $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, co.code, co.label, c.nom as label2"; //
-        $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d";
-        $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid";
-        $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region";
-        $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_country as co on d.country = co.rowid";
-        $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid";
-        $sql.=" WHERE d.entity IN (".getEntity('adherent').")";
-        $sql.=" AND d.statut = 1";
-        $sql.=" GROUP BY co.label, co.code, c.nom";
+        $sql .= "SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, co.code, co.label, c.nom as label2"; //
+        $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d";
+        $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid";
+        $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region";
+        $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co on d.country = co.rowid";
+        $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid";
+        $sql .= " WHERE d.entity IN (".getEntity('adherent').")";
+        $sql .= " AND d.statut = 1";
+        $sql .= " GROUP BY co.label, co.code, c.nom";
         //print $sql;
     }
     if ($mode == 'memberbyregion') //
     {
-        $label=$langs->trans("Country");
-        $label2=$langs->trans("Region"); //département
-        $tab='statsregion'; //onglet
+        $label = $langs->trans("Country");
+        $label2 = $langs->trans("Region"); //département
+        $tab = 'statsregion'; //onglet
 
         $data = array(); //tableau de donnée
-        $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, co.code, co.label, r.nom as label2";
-        $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d";
-        $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid";
-        $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region";
-        $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_country as co on d.country = co.rowid";
-        $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid";
-        $sql.=" WHERE d.entity IN (".getEntity('adherent').")";
-        $sql.=" AND d.statut = 1";
-        $sql.=" GROUP BY co.label, co.code, r.nom"; //+
+        $sql .= "SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, co.code, co.label, r.nom as label2";
+        $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d";
+        $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid";
+        $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region";
+        $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co on d.country = co.rowid";
+        $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid";
+        $sql .= " WHERE d.entity IN (".getEntity('adherent').")";
+        $sql .= " AND d.statut = 1";
+        $sql .= " GROUP BY co.label, co.code, r.nom"; //+
         //print $sql;
     }
     if ($mode == 'memberbytown')
     {
-        $label=$langs->trans("Country");
-        $label2=$langs->trans("Town");
-        $tab='statstown';
+        $label = $langs->trans("Country");
+        $label2 = $langs->trans("Town");
+        $tab = 'statstown';
 
         $data = array();
-        $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, c.code, c.label, d.town as label2";
-        $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d";
-        $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_country as c on d.country = c.rowid";
-        $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid";
-        $sql.=" WHERE d.entity IN (".getEntity('adherent').")";
-        $sql.=" AND d.statut = 1";
-        $sql.=" GROUP BY c.label, c.code, d.town";
+        $sql .= "SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, c.code, c.label, d.town as label2";
+        $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d";
+        $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c on d.country = c.rowid";
+        $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid";
+        $sql .= " WHERE d.entity IN (".getEntity('adherent').")";
+        $sql .= " AND d.statut = 1";
+        $sql .= " GROUP BY c.label, c.code, d.town";
         //print $sql;
     }
 
-    $langsen=new Translate('', $conf);
+    $langsen = new Translate('', $conf);
     $langsen->setDefaultLang('en_US');
     $langsen->load("dict");
     //print $langsen->trans("Country"."FI");exit;
 
     // Define $data array
     dol_syslog("Count member", LOG_DEBUG);
-    $resql=$db->query($sql);
+    $resql = $db->query($sql);
     if ($resql)
     {
-        $num=$db->num_rows($resql);
-        $i=0;
+        $num = $db->num_rows($resql);
+        $i = 0;
         while ($i < $num)
         {
-            $obj=$db->fetch_object($resql);
+            $obj = $db->fetch_object($resql);
             if ($mode == 'memberbycountry')
             {
-                $data[]=array('label'=>(($obj->code && $langs->trans("Country".$obj->code)!="Country".$obj->code)?$langs->trans("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))),
-                            'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code)!="Country".$obj->code)?$langsen->transnoentitiesnoconv("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))),
+                $data[] = array('label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))),
+                            'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))),
 							'code'=>$obj->code,
 							'nb'=>$obj->nb,
 							'lastdate'=>$db->jdate($obj->lastdate),
@@ -167,10 +167,10 @@ if ($mode)
             }
             if ($mode == 'memberbyregion') //+
             {
-                $data[]=array(
-                    'label'=>(($obj->code && $langs->trans("Country".$obj->code)!="Country".$obj->code)?$langs->trans("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))),
-                    'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code)!="Country".$obj->code)?$langsen->transnoentitiesnoconv("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))),
-				    'label2'=>($obj->label2?$obj->label2:$langs->trans("Unknown")),
+                $data[] = array(
+                    'label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))),
+                    'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))),
+				    'label2'=>($obj->label2 ? $obj->label2 : $langs->trans("Unknown")),
 					'nb'=>$obj->nb,
 					'lastdate'=>$db->jdate($obj->lastdate),
                     'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate)
@@ -178,9 +178,9 @@ if ($mode)
 	        }
             if ($mode == 'memberbystate')
             {
-                $data[]=array('label'=>(($obj->code && $langs->trans("Country".$obj->code)!="Country".$obj->code)?$langs->trans("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))),
-                            'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code)!="Country".$obj->code)?$langsen->transnoentitiesnoconv("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))),
-				            'label2'=>($obj->label2?$obj->label2:$langs->trans("Unknown")),
+                $data[] = array('label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))),
+                            'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))),
+				            'label2'=>($obj->label2 ? $obj->label2 : $langs->trans("Unknown")),
 							'nb'=>$obj->nb,
 							'lastdate'=>$db->jdate($obj->lastdate),
                             'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate)
@@ -188,9 +188,9 @@ if ($mode)
             }
             if ($mode == 'memberbytown')
             {
-                $data[]=array('label'=>(($obj->code && $langs->trans("Country".$obj->code)!="Country".$obj->code)?$langs->trans("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))),
-                            'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code)!="Country".$obj->code)?$langsen->transnoentitiesnoconv("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))),
-                            'label2'=>($obj->label2?$obj->label2:$langs->trans("Unknown")),
+                $data[] = array('label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))),
+                            'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))),
+                            'label2'=>($obj->label2 ? $obj->label2 : $langs->trans("Unknown")),
                             'nb'=>$obj->nb,
                             'lastdate'=>$db->jdate($obj->lastdate),
                             'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate)
@@ -214,7 +214,7 @@ dol_fiche_head($head, $tab, $langs->trans("Statistics"), -1, 'user');
 
 
 // Print title
-if ($mode && ! count($data))
+if ($mode && !count($data))
 {
     print $langs->trans("NoValidatedMemberYet").'<br>';
     print '<br>';
@@ -224,7 +224,7 @@ else
     if ($mode == 'memberbycountry') print $langs->trans("MembersByCountryDesc").'<br>';
     elseif ($mode == 'memberbystate') print $langs->trans("MembersByStateDesc").'<br>';
     elseif ($mode == 'memberbytown') print $langs->trans("MembersByTownDesc").'<br>';
-    elseif ($mode == 'memberbyregion') print $langs->trans("MembersByRegion").'<br>';//+
+    elseif ($mode == 'memberbyregion') print $langs->trans("MembersByRegion").'<br>'; //+
     else
     {
         print $langs->trans("MembersStatisticsDesc").'<br>';
@@ -234,8 +234,8 @@ else
         print '<a href="'.$_SERVER["PHP_SELF"].'?mode=memberbystate">'.$langs->trans("MembersStatisticsByState").'</a><br>';
         print '<br>';
         print '<a href="'.$_SERVER["PHP_SELF"].'?mode=memberbytown">'.$langs->trans("MembersStatisticsByTown").'</a><br>';
-        print '<br>';//+
-		print '<a href="'.$_SERVER["PHP_SELF"].'?mode=memberbyregion">'.$langs->trans("MembersStatisticsByRegion").'</a><br>';//+
+        print '<br>'; //+
+		print '<a href="'.$_SERVER["PHP_SELF"].'?mode=memberbyregion">'.$langs->trans("MembersStatisticsByRegion").'</a><br>'; //+
     }
     print '<br>';
 }
@@ -260,16 +260,16 @@ if (count($arrayjs) && $mode == 'memberbycountry')
     print "\tdata.addColumn('number', 'Number');\n";
 
     // loop and dump
-    $i=0;
-    foreach($data as $val)
+    $i = 0;
+    foreach ($data as $val)
     {
-        $valcountry=strtoupper($val['code']);    // Should be ISO-3166 code (faster)
+        $valcountry = strtoupper($val['code']); // Should be ISO-3166 code (faster)
         //$valcountry=ucfirst($val['label_en']);
         if ($valcountry == 'Great Britain') { $valcountry = 'United Kingdom'; }    // fix case of uk (when we use labels)
         print "\tdata.setValue(".$i.", 0, \"".$valcountry."\");\n";
         print "\tdata.setValue(".$i.", 1, ".$val['nb'].");\n";
         // Google's Geomap only supports up to 400 entries
-        if ($i >= 400){ break; }
+        if ($i >= 400) { break; }
         $i++;
     }
 

+ 21 - 21
htdocs/adherents/stats/index.php

@@ -28,11 +28,11 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherentstats.class.php';
 require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
 
-$WIDTH=DolGraph::getDefaultGraphSizeForStats('width');
-$HEIGHT=DolGraph::getDefaultGraphSizeForStats('height');
+$WIDTH = DolGraph::getDefaultGraphSizeForStats('width');
+$HEIGHT = DolGraph::getDefaultGraphSizeForStats('height');
 
-$userid=GETPOST('userid', 'int'); if ($userid < 0) $userid=0;
-$socid=GETPOST('socid', 'int'); if ($socid < 0) $socid=0;
+$userid = GETPOST('userid', 'int'); if ($userid < 0) $userid = 0;
+$socid = GETPOST('socid', 'int'); if ($socid < 0) $socid = 0;
 
 // Security check
 if ($user->socid > 0)
@@ -40,28 +40,28 @@ if ($user->socid > 0)
     $action = '';
     $socid = $user->socid;
 }
-$result=restrictedArea($user, 'adherent', '', '', 'cotisation');
+$result = restrictedArea($user, 'adherent', '', '', 'cotisation');
 
 $year = strftime("%Y", time());
-$startyear=$year-2;
-$endyear=$year;
+$startyear = $year - 2;
+$endyear = $year;
 
 // Load translation files required by the page
-$langs->loadLangs(array("companies","members"));
+$langs->loadLangs(array("companies", "members"));
 
 
 /*
  * View
  */
 
-$form=new Form($db);
+$form = new Form($db);
 
 $title = $langs->trans("SubscriptionsStatistics");
 llxHeader('', $title);
 
 print load_fiche_titre($title, '', 'members');
 
-$dir=$conf->adherent->dir_temp;
+$dir = $conf->adherent->dir_temp;
 
 dol_mkdir($dir);
 
@@ -79,13 +79,13 @@ $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=memberstats&file=subscripti
 
 $px1 = new DolGraph();
 $mesg = $px1->isGraphKo();
-if (! $mesg)
+if (!$mesg)
 {
     $px1->SetData($data);
-    $i=$startyear;
+    $i = $startyear;
     while ($i <= $endyear)
     {
-        $legend[]=$i;
+        $legend[] = $i;
         $i++;
     }
     $px1->SetLegend($legend);
@@ -96,7 +96,7 @@ if (! $mesg)
     $px1->SetYLabel($langs->trans("NbOfSubscriptions"));
     $px1->SetShading(3);
     $px1->SetHorizTickIncrement(1);
-    $px1->mode='depth';
+    $px1->mode = 'depth';
     $px1->SetTitle($langs->trans("NbOfSubscriptions"));
 
     $px1->draw($filenamenb, $fileurlnb);
@@ -112,13 +112,13 @@ $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=memberstats&file=subscr
 
 $px2 = new DolGraph();
 $mesg = $px2->isGraphKo();
-if (! $mesg)
+if (!$mesg)
 {
     $px2->SetData($data);
-    $i=$startyear;
+    $i = $startyear;
     while ($i <= $endyear)
     {
-        $legend[]=$i;
+        $legend[] = $i;
         $i++;
     }
     $px2->SetLegend($legend);
@@ -129,7 +129,7 @@ if (! $mesg)
     $px2->SetYLabel($langs->trans("AmountOfSubscriptions"));
     $px2->SetShading(3);
     $px2->SetHorizTickIncrement(1);
-    $px2->mode='depth';
+    $px2->mode = 'depth';
     $px2->SetTitle($langs->trans("AmountOfSubscriptions"));
 
     $px2->draw($filenameamount, $fileurlamount);
@@ -174,11 +174,11 @@ print '<td class="right">'.$langs->trans("AmountTotal").'</td>';
 print '<td class="right">'.$langs->trans("AmountAverage").'</td>';
 print '</tr>';
 
-$oldyear=0;
+$oldyear = 0;
 foreach ($data as $val)
 {
     $year = $val['year'];
-    while ($oldyear > $year+1)
+    while ($oldyear > $year + 1)
     {	// If we have empty year
         $oldyear--;
         print '<tr class="oddeven" height="24">';
@@ -202,7 +202,7 @@ foreach ($data as $val)
     print '<td class="right">'.price(price2num($val['total'], 'MT'), 1).'</td>';
     print '<td class="right">'.price(price2num($val['avg'], 'MT'), 1).'</td>';
     print '</tr>';
-    $oldyear=$year;
+    $oldyear = $year;
 }
 
 print '</table>';

+ 10 - 10
htdocs/adherents/subscription.php

@@ -81,33 +81,33 @@ if ($rowid)
     $result = $object->fetch($rowid);
 
     // Define variables to know what current user can do on users
-    $canadduser=($user->admin || $user->rights->user->user->creer);
+    $canadduser = ($user->admin || $user->rights->user->user->creer);
     // Define variables to know what current user can do on properties of user linked to edited member
     if ($object->user_id)
     {
         // $user is the user editing, $object->user_id is the user's id linked to the edited member
-        $caneditfielduser=( (($user->id == $object->user_id) && $user->rights->user->self->creer)
-        || (($user->id != $object->user_id) && $user->rights->user->user->creer) );
-        $caneditpassworduser=( (($user->id == $object->user_id) && $user->rights->user->self->password)
-        || (($user->id != $object->user_id) && $user->rights->user->user->password) );
+        $caneditfielduser = ((($user->id == $object->user_id) && $user->rights->user->self->creer)
+        || (($user->id != $object->user_id) && $user->rights->user->user->creer));
+        $caneditpassworduser = ((($user->id == $object->user_id) && $user->rights->user->self->password)
+        || (($user->id != $object->user_id) && $user->rights->user->user->password));
     }
 }
 
 // Define variables to know what current user can do on members
-$canaddmember=$user->rights->adherent->creer;
+$canaddmember = $user->rights->adherent->creer;
 // Define variables to know what current user can do on properties of a member
 if ($rowid)
 {
-    $caneditfieldmember=$user->rights->adherent->creer;
+    $caneditfieldmember = $user->rights->adherent->creer;
 }
 
 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
 $hookmanager->initHooks(array('subscription'));
 
 // PDF
-$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
-$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
-$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
+$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
+$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
+$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
 
 
 /*

+ 2 - 2
htdocs/adherents/subscription/info.php

@@ -29,12 +29,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
 require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php';
 
 // Load translation files required by the page
-$langs->loadLangs(array("companies","members","bills","users"));
+$langs->loadLangs(array("companies", "members", "bills", "users"));
 
 if (!$user->rights->adherent->lire)
 	accessforbidden();
 
-$rowid=GETPOST("rowid", 'int');
+$rowid = GETPOST("rowid", 'int');
 
 
 

+ 4 - 4
htdocs/adherents/type_translation.php

@@ -71,21 +71,21 @@ if ($action == 'vadd' && $cancel != $langs->trans("Cancel") && $user->rights->ad
 	$current_lang = $langs->getDefaultLang();
 
 	// update of object
-	if ( $_POST["forcelangprod"] == $current_lang )
+	if ($_POST["forcelangprod"] == $current_lang)
 	{
 		$object->label			= $_POST["libelle"];
-		$object->description	= dol_htmlcleanlastbr($_POST["desc"]);
+		$object->description = dol_htmlcleanlastbr($_POST["desc"]);
 		$object->other			= dol_htmlcleanlastbr($_POST["other"]);
 	}
 	else
 	{
 		$object->multilangs[$_POST["forcelangprod"]]["label"]		= $_POST["libelle"];
-		$object->multilangs[$_POST["forcelangprod"]]["description"]	= dol_htmlcleanlastbr($_POST["desc"]);
+		$object->multilangs[$_POST["forcelangprod"]]["description"] = dol_htmlcleanlastbr($_POST["desc"]);
 		$object->multilangs[$_POST["forcelangprod"]]["other"]		= dol_htmlcleanlastbr($_POST["other"]);
 	}
 
 	// backup into database
-	if ( $object->setMultiLangs($user) > 0 )
+	if ($object->setMultiLangs($user) > 0)
 	{
 		$action = '';
 	}

+ 23 - 23
htdocs/admin/accountant.php

@@ -28,27 +28,27 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
 
-$action=GETPOST('action', 'aZ09');
-$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'adminaccoutant';   // To manage different context of search
+$action = GETPOST('action', 'aZ09');
+$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'adminaccoutant'; // To manage different context of search
 
 // Load translation files required by the page
 $langs->loadLangs(array('admin', 'companies'));
 
-if (! $user->admin) accessforbidden();
+if (!$user->admin) accessforbidden();
 
-$error=0;
+$error = 0;
 
 
 /*
  * 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 == 'update' && ! GETPOST("cancel", 'alpha'))
-|| ($action == 'updateedit') )
+if (($action == 'update' && !GETPOST("cancel", 'alpha'))
+|| ($action == 'updateedit'))
 {
 	dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_NAME", GETPOST("nom", 'nohtml'), 'chaine', 0, '', $conf->entity);
 	dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_ADDRESS", GETPOST("address", 'nohtml'), 'chaine', 0, '', $conf->entity);
@@ -64,7 +64,7 @@ if ( ($action == 'update' && ! GETPOST("cancel", 'alpha'))
 	dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_CODE", GETPOST("code", 'nohtml'), 'chaine', 0, '', $conf->entity);
 	dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_NOTE", GETPOST("note", 'none'), 'chaine', 0, '', $conf->entity);
 
-	if ($action != 'updateedit' && ! $error)
+	if ($action != 'updateedit' && !$error)
 	{
 		header("Location: ".$_SERVER["PHP_SELF"]);
 		exit;
@@ -75,7 +75,7 @@ if ( ($action == 'update' && ! GETPOST("cancel", 'alpha'))
  * View
  */
 
-$help_url='';
+$help_url = '';
 llxHeader('', $langs->trans("CompanyFoundation"), $help_url);
 
 print load_fiche_titre($langs->trans("CompanyFoundation"), '', 'title_setup');
@@ -84,11 +84,11 @@ $head = company_admin_prepare_head();
 
 dol_fiche_head($head, 'accountant', $langs->trans("Company"), -1, 'company');
 
-$form=new Form($db);
-$formother=new FormOther($db);
-$formcompany=new FormCompany($db);
+$form = new Form($db);
+$formother = new FormOther($db);
+$formcompany = new FormCompany($db);
 
-$countrynotdefined='<font class="error">'.$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')</font>';
+$countrynotdefined = '<font class="error">'.$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')</font>';
 
 print '<span class="opacitymedium">'.$langs->trans("AccountantDesc")."</span><br>\n";
 print "<br>\n";
@@ -114,17 +114,17 @@ print '<tr class="liste_titre"><th class="titlefield wordbreak">'.$langs->trans(
 
 // Name
 print '<tr class="oddeven"><td><label for="name">'.$langs->trans("CompanyName").'</label></td><td>';
-print '<input name="nom" id="name" class="minwidth200" value="'. ($conf->global->MAIN_INFO_ACCOUNTANT_NAME?$conf->global->MAIN_INFO_ACCOUNTANT_NAME: GETPOST("nom", 'nohtml')) . '"'.(empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '' : ' autofocus="autofocus"').'></td></tr>'."\n";
+print '<input name="nom" id="name" class="minwidth200" value="'.($conf->global->MAIN_INFO_ACCOUNTANT_NAME ? $conf->global->MAIN_INFO_ACCOUNTANT_NAME : GETPOST("nom", 'nohtml')).'"'.(empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '' : ' autofocus="autofocus"').'></td></tr>'."\n";
 
 // Address
 print '<tr class="oddeven"><td><label for="address">'.$langs->trans("CompanyAddress").'</label></td><td>';
-print '<textarea name="address" id="address" class="quatrevingtpercent" rows="'.ROWS_3.'">'. ($conf->global->MAIN_INFO_ACCOUNTANT_ADDRESS?$conf->global->MAIN_INFO_ACCOUNTANT_ADDRESS: GETPOST("address", 'nohtml')) . '</textarea></td></tr>'."\n";
+print '<textarea name="address" id="address" class="quatrevingtpercent" rows="'.ROWS_3.'">'.($conf->global->MAIN_INFO_ACCOUNTANT_ADDRESS ? $conf->global->MAIN_INFO_ACCOUNTANT_ADDRESS : GETPOST("address", 'nohtml')).'</textarea></td></tr>'."\n";
 
 print '<tr class="oddeven"><td><label for="zipcode">'.$langs->trans("CompanyZip").'</label></td><td>';
-print '<input class="minwidth100" name="zipcode" id="zipcode" value="'. ($conf->global->MAIN_INFO_ACCOUNTANT_ZIP?$conf->global->MAIN_INFO_ACCOUNTANT_ZIP: GETPOST("zipcode", 'alpha')) . '"></td></tr>'."\n";
+print '<input class="minwidth100" name="zipcode" id="zipcode" value="'.($conf->global->MAIN_INFO_ACCOUNTANT_ZIP ? $conf->global->MAIN_INFO_ACCOUNTANT_ZIP : GETPOST("zipcode", 'alpha')).'"></td></tr>'."\n";
 
 print '<tr class="oddeven"><td><label for="town">'.$langs->trans("CompanyTown").'</label></td><td>';
-print '<input name="town" class="minwidth100" id="town" value="'. ($conf->global->MAIN_INFO_ACCOUNTANT_TOWN?$conf->global->MAIN_INFO_ACCOUNTANT_TOWN: GETPOST("town", 'nohtml')) . '"></td></tr>'."\n";
+print '<input name="town" class="minwidth100" id="town" value="'.($conf->global->MAIN_INFO_ACCOUNTANT_TOWN ? $conf->global->MAIN_INFO_ACCOUNTANT_TOWN : GETPOST("town", 'nohtml')).'"></td></tr>'."\n";
 
 // Country
 print '<tr class="oddeven"><td><label for="selectcountry_id">'.$langs->trans("Country").'</label></td><td class="maxwidthonsmartphone">';
@@ -139,28 +139,28 @@ print '</td></tr>'."\n";
 
 print '<tr class="oddeven"><td><label for="phone">'.$langs->trans("Phone").'</label></td><td>';
 print img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright');
-print '<input name="tel" id="phone" value="'. $conf->global->MAIN_INFO_ACCOUNTANT_PHONE . '"></td></tr>';
+print '<input name="tel" id="phone" value="'.$conf->global->MAIN_INFO_ACCOUNTANT_PHONE.'"></td></tr>';
 print '</td></tr>'."\n";
 
 print '<tr class="oddeven"><td><label for="fax">'.$langs->trans("Fax").'</label></td><td>';
 print img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright');
-print '<input name="fax" id="fax" value="'. $conf->global->MAIN_INFO_ACCOUNTANT_FAX . '"></td></tr>';
+print '<input name="fax" id="fax" value="'.$conf->global->MAIN_INFO_ACCOUNTANT_FAX.'"></td></tr>';
 print '</td></tr>'."\n";
 
 print '<tr class="oddeven"><td><label for="email">'.$langs->trans("EMail").'</label></td><td>';
 print img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright');
-print '<input name="mail" id="email" class="minwidth200" value="'. $conf->global->MAIN_INFO_ACCOUNTANT_MAIL . '"></td></tr>';
+print '<input name="mail" id="email" class="minwidth200" value="'.$conf->global->MAIN_INFO_ACCOUNTANT_MAIL.'"></td></tr>';
 print '</td></tr>'."\n";
 
 // Web
 print '<tr class="oddeven"><td><label for="web">'.$langs->trans("Web").'</label></td><td>';
 print img_picto('', 'globe', '', false, 0, 0, '', 'paddingright');
-print '<input name="web" id="web" class="minwidth300" value="'. $conf->global->MAIN_INFO_ACCOUNTANT_WEB . '"></td></tr>';
+print '<input name="web" id="web" class="minwidth300" value="'.$conf->global->MAIN_INFO_ACCOUNTANT_WEB.'"></td></tr>';
 print '</td></tr>'."\n";
 
 // Code
 print '<tr class="oddeven"><td><label for="code">'.$langs->trans("AccountantFileNumber").'</label></td><td>';
-print '<input name="code" id="code" class="minwidth100" value="'. ($conf->global->MAIN_INFO_ACCOUNTANT_CODE?$conf->global->MAIN_INFO_ACCOUNTANT_CODE: GETPOST("code", 'nohtml')) . '"></td></tr>'."\n";
+print '<input name="code" id="code" class="minwidth100" value="'.($conf->global->MAIN_INFO_ACCOUNTANT_CODE ? $conf->global->MAIN_INFO_ACCOUNTANT_CODE : GETPOST("code", 'nohtml')).'"></td></tr>'."\n";
 
 // Note
 print '<tr class="oddeven"><td class="tdtop"><label for="note">'.$langs->trans("Note").'</label></td><td>';

+ 1 - 1
htdocs/admin/agenda.php

@@ -172,7 +172,7 @@ if (!empty($triggers))
 
 		// If 'element' value is myobject@mymodule instead of mymodule
 		$tmparray = explode('@', $module);
-		if (! empty($tmparray[1])) {
+		if (!empty($tmparray[1])) {
 			$module = $tmparray[1];
 		}
 

+ 11 - 11
htdocs/admin/agenda_extrafields.php

@@ -41,13 +41,13 @@ $extrafields = new ExtraFields($db);
 $form = new Form($db);
 
 // List of supported format
-$tmptype2label=ExtraFields::$type2label;
-$type2label=array('');
-foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
+$tmptype2label = ExtraFields::$type2label;
+$type2label = array('');
+foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val);
 
-$action=GETPOST('action', 'alpha');
-$attrname=GETPOST('attrname', 'alpha');
-$elementtype='actioncomm'; //Must be the $table_element of the class that manage extrafield
+$action = GETPOST('action', 'alpha');
+$attrname = GETPOST('attrname', 'alpha');
+$elementtype = 'actioncomm'; //Must be the $table_element of the class that manage extrafield
 
 if (!$user->admin) accessforbidden();
 
@@ -64,15 +64,15 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
  * View
  */
 
-$textobject=$langs->transnoentitiesnoconv("Agenda");
+$textobject = $langs->transnoentitiesnoconv("Agenda");
 
-$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');
 
-$head=agenda_prepare_head();
+$head = agenda_prepare_head();
 
 dol_fiche_head($head, 'attributes', $langs->trans("Agenda"), -1, 'action');
 
@@ -109,7 +109,7 @@ if ($action == 'create')
 /* Edition of an optional field                                                */
 /*                                                                            */
 /* ************************************************************************** */
-if ($action == 'edit' && ! empty($attrname))
+if ($action == 'edit' && !empty($attrname))
 {
     print "<br>";
     print load_fiche_titre($langs->trans("FieldEdition", $attrname));

+ 54 - 54
htdocs/admin/agenda_extsites.php

@@ -38,14 +38,14 @@ if (!$user->admin) accessforbidden();
 $langs->loadLangs(array('agenda', 'admin', 'other'));
 
 $def = array();
-$actiontest=GETPOST('test', 'alpha');
-$actionsave=GETPOST('save', 'alpha');
+$actiontest = GETPOST('test', 'alpha');
+$actionsave = GETPOST('save', 'alpha');
 
-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;
 
 // List of available colors
-$colorlist=array('BECEDD','DDBECE','BFDDBE','F598B4','F68654','CBF654','A4A4A5');
+$colorlist = array('BECEDD', 'DDBECE', 'BFDDBE', 'F598B4', 'F68654', 'CBF654', 'A4A4A5');
 
 
 /*
@@ -56,23 +56,23 @@ if ($actionsave)
 {
     $db->begin();
 
-    $disableext=GETPOST('AGENDA_DISABLE_EXT', 'alpha');
-	$res=dolibarr_set_const($db, 'AGENDA_DISABLE_EXT', $disableext, 'chaine', 0, '', $conf->entity);
+    $disableext = GETPOST('AGENDA_DISABLE_EXT', 'alpha');
+	$res = dolibarr_set_const($db, 'AGENDA_DISABLE_EXT', $disableext, 'chaine', 0, '', $conf->entity);
 
-	$i=1; $errorsaved=0;
-	$error=0;
+	$i = 1; $errorsaved = 0;
+	$error = 0;
 
 	// Save agendas
 	while ($i <= $MAXAGENDA)
 	{
-		$name=trim(GETPOST('AGENDA_EXT_NAME'.$i, 'alpha'));
-		$src=trim(GETPOST('AGENDA_EXT_SRC'.$i, 'alpha'));
-		$offsettz=trim(GETPOST('AGENDA_EXT_OFFSETTZ'.$i, 'alpha'));
-		$color=trim(GETPOST('AGENDA_EXT_COLOR'.$i, 'alpha'));
-		if ($color=='-1') $color='';
-		$enabled=trim(GETPOST('AGENDA_EXT_ENABLED'.$i, 'alpha'));
-
-		if (! empty($src) && ! dol_is_url($src))
+		$name = trim(GETPOST('AGENDA_EXT_NAME'.$i, 'alpha'));
+		$src = trim(GETPOST('AGENDA_EXT_SRC'.$i, 'alpha'));
+		$offsettz = trim(GETPOST('AGENDA_EXT_OFFSETTZ'.$i, 'alpha'));
+		$color = trim(GETPOST('AGENDA_EXT_COLOR'.$i, 'alpha'));
+		if ($color == '-1') $color = '';
+		$enabled = trim(GETPOST('AGENDA_EXT_ENABLED'.$i, 'alpha'));
+
+		if (!empty($src) && !dol_is_url($src))
 		{
 			setEventMessages($langs->trans("ErrorParamMustBeAnUrl"), null, 'errors');
 			$error++;
@@ -81,29 +81,29 @@ if ($actionsave)
 		}
 
 		//print '-name='.$name.'-color='.$color;
-		$res=dolibarr_set_const($db, 'AGENDA_EXT_NAME'.$i, $name, 'chaine', 0, '', $conf->entity);
-		if (! $res > 0) $error++;
-		$res=dolibarr_set_const($db, 'AGENDA_EXT_SRC'.$i, $src, 'chaine', 0, '', $conf->entity);
-		if (! $res > 0) $error++;
-		$res=dolibarr_set_const($db, 'AGENDA_EXT_OFFSETTZ'.$i, $offsettz, 'chaine', 0, '', $conf->entity);
-		if (! $res > 0) $error++;
-		$res=dolibarr_set_const($db, 'AGENDA_EXT_COLOR'.$i, $color, 'chaine', 0, '', $conf->entity);
-		if (! $res > 0) $error++;
-		$res=dolibarr_set_const($db, 'AGENDA_EXT_ENABLED'.$i, $enabled, 'chaine', 0, '', $conf->entity);
-		if (! $res > 0) $error++;
+		$res = dolibarr_set_const($db, 'AGENDA_EXT_NAME'.$i, $name, 'chaine', 0, '', $conf->entity);
+		if (!$res > 0) $error++;
+		$res = dolibarr_set_const($db, 'AGENDA_EXT_SRC'.$i, $src, 'chaine', 0, '', $conf->entity);
+		if (!$res > 0) $error++;
+		$res = dolibarr_set_const($db, 'AGENDA_EXT_OFFSETTZ'.$i, $offsettz, 'chaine', 0, '', $conf->entity);
+		if (!$res > 0) $error++;
+		$res = dolibarr_set_const($db, 'AGENDA_EXT_COLOR'.$i, $color, 'chaine', 0, '', $conf->entity);
+		if (!$res > 0) $error++;
+		$res = dolibarr_set_const($db, 'AGENDA_EXT_ENABLED'.$i, $enabled, 'chaine', 0, '', $conf->entity);
+		if (!$res > 0) $error++;
 		$i++;
 	}
 
 	// Save nb of agenda
-	if (! $error)
+	if (!$error)
 	{
-		$res=dolibarr_set_const($db, 'AGENDA_EXT_NB', trim(GETPOST('AGENDA_EXT_NB', 'int')), 'chaine', 0, '', $conf->entity);
-		if (! $res > 0) $error++;
-		if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB=5;
-		$MAXAGENDA=empty($conf->global->AGENDA_EXT_NB)?5:$conf->global->AGENDA_EXT_NB;
+		$res = dolibarr_set_const($db, 'AGENDA_EXT_NB', trim(GETPOST('AGENDA_EXT_NB', 'int')), 'chaine', 0, '', $conf->entity);
+		if (!$res > 0) $error++;
+		if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB = 5;
+		$MAXAGENDA = empty($conf->global->AGENDA_EXT_NB) ? 5 : $conf->global->AGENDA_EXT_NB;
 	}
 
-    if (! $error)
+    if (!$error)
     {
         $db->commit();
         setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
@@ -119,24 +119,24 @@ if ($actionsave)
  * View
  */
 
-$form=new Form($db);
-$formadmin=new FormAdmin($db);
-$formother=new FormOther($db);
+$form = new Form($db);
+$formadmin = new FormAdmin($db);
+$formother = new FormOther($db);
 
-$arrayofjs=array();
-$arrayofcss=array();
+$arrayofjs = array();
+$arrayofcss = array();
 
-$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, '', 0, 0, $arrayofjs, $arrayofcss);
 
-$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 name="extsitesconfig" action="'.$_SERVER["PHP_SELF"].'" method="post">';
 print '<input type="hidden" name="token" value="'.newToken().'">';
 print '<input type="hidden" name="action" value="save">';
 
-$head=agenda_prepare_head();
+$head = agenda_prepare_head();
 
 dol_fiche_head($head, 'extsites', $langs->trans("Agenda"), -1, 'action');
 
@@ -144,8 +144,8 @@ print '<span class="opacitymedium">'.$langs->trans("AgendaExtSitesDesc")."</span
 print "<br>\n";
 
 
-$selectedvalue=$conf->global->AGENDA_DISABLE_EXT;
-if ($selectedvalue==1) $selectedvalue=0; else $selectedvalue=1;
+$selectedvalue = $conf->global->AGENDA_DISABLE_EXT;
+if ($selectedvalue == 1) $selectedvalue = 0; else $selectedvalue = 1;
 
 print "<table class=\"noborder\" width=\"100%\">";
 
@@ -199,30 +199,30 @@ print "<td>".$form->textwithpicto($langs->trans("FixTZ"), $langs->trans("FillFix
 print '<td class="right">'.$langs->trans("Color").'</td>';
 print "</tr>";
 
-$i=1;
+$i = 1;
 while ($i <= $MAXAGENDA)
 {
-	$key=$i;
-	$name='AGENDA_EXT_NAME'.$key;
-	$src='AGENDA_EXT_SRC'.$key;
-	$offsettz='AGENDA_EXT_OFFSETTZ'.$key;
-	$color='AGENDA_EXT_COLOR'.$key;
-	$enabled='AGENDA_EXT_ENABLED'.$key;
+	$key = $i;
+	$name = 'AGENDA_EXT_NAME'.$key;
+	$src = 'AGENDA_EXT_SRC'.$key;
+	$offsettz = 'AGENDA_EXT_OFFSETTZ'.$key;
+	$color = 'AGENDA_EXT_COLOR'.$key;
+	$enabled = 'AGENDA_EXT_ENABLED'.$key;
 
 
 	print '<tr class="oddeven">';
 	// Nb
 	print '<td width="180" class="nowrap">'.$langs->trans("AgendaExtNb", $key)."</td>";
 	// Name
-	print '<td><input type="text" class="flat hideifnotset" name="AGENDA_EXT_NAME'.$key.'" value="'. (GETPOST('AGENDA_EXT_NAME'.$key)?GETPOST('AGENDA_EXT_NAME'.$key, 'alpha'):$conf->global->$name) . '" size="28"></td>';
+	print '<td><input type="text" class="flat hideifnotset" name="AGENDA_EXT_NAME'.$key.'" value="'.(GETPOST('AGENDA_EXT_NAME'.$key) ?GETPOST('AGENDA_EXT_NAME'.$key, 'alpha') : $conf->global->$name).'" size="28"></td>';
 	// URL
-	print '<td><input type="url" class="flat hideifnotset" name="AGENDA_EXT_SRC'.$key.'" value="'. (GETPOST('AGENDA_EXT_SRC'.$key)?GETPOST('AGENDA_EXT_SRC'.$key, 'alpha'):$conf->global->$src) . '" size="60"></td>';
+	print '<td><input type="url" class="flat hideifnotset" name="AGENDA_EXT_SRC'.$key.'" value="'.(GETPOST('AGENDA_EXT_SRC'.$key) ?GETPOST('AGENDA_EXT_SRC'.$key, 'alpha') : $conf->global->$src).'" size="60"></td>';
 	// Offset TZ
-	print '<td><input type="text" class="flat hideifnotset" name="AGENDA_EXT_OFFSETTZ'.$key.'" value="'. (GETPOST('AGENDA_EXT_OFFSETTZ'.$key)?GETPOST('AGENDA_EXT_OFFSETTZ'.$key):$conf->global->$offsettz) . '" size="2"></td>';
+	print '<td><input type="text" class="flat hideifnotset" name="AGENDA_EXT_OFFSETTZ'.$key.'" value="'.(GETPOST('AGENDA_EXT_OFFSETTZ'.$key) ?GETPOST('AGENDA_EXT_OFFSETTZ'.$key) : $conf->global->$offsettz).'" size="2"></td>';
 	// Color (Possible colors are limited by Google)
 	print '<td class="nowrap right">';
 	//print $formadmin->selectColor($conf->global->$color, "google_agenda_color".$key, $colorlist);
-	print $formother->selectColor((GETPOST("AGENDA_EXT_COLOR".$key)?GETPOST("AGENDA_EXT_COLOR".$key):$conf->global->$color), "AGENDA_EXT_COLOR".$key, 'extsitesconfig', 1, '', 'hideifnotset');
+	print $formother->selectColor((GETPOST("AGENDA_EXT_COLOR".$key) ?GETPOST("AGENDA_EXT_COLOR".$key) : $conf->global->$color), "AGENDA_EXT_COLOR".$key, 'extsitesconfig', 1, '', 'hideifnotset');
 	print '</td>';
 	print "</tr>";
 	$i++;

+ 1 - 1
htdocs/admin/agenda_other.php

@@ -324,7 +324,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
 }
 
 print '<form action="'.$_SERVER["PHP_SELF"].'" name="agenda">';
-print '<input type="hidden" name="token" value="' . newToken() . '">';
+print '<input type="hidden" name="token" value="'.newToken().'">';
 print '<input type="hidden" name="action" value="set">';
 
 print '<table class="noborder allwidth">'."\n";

+ 16 - 16
htdocs/admin/agenda_reminder.php

@@ -30,7 +30,7 @@ if (!$user->admin)
     accessforbidden();
 
 // Load translation files required by the page
-$langs->loadLangs(array("admin","other","agenda"));
+$langs->loadLangs(array("admin", "other", "agenda"));
 
 $action = GETPOST('action', 'alpha');
 $value = GETPOST('value', 'alpha');
@@ -48,8 +48,8 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
 
 if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
 {
-	$code=$reg[1];
-	$value=(GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1);
+	$code = $reg[1];
+	$value = (GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1);
 	if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0)
 	{
 		Header("Location: ".$_SERVER["PHP_SELF"]);
@@ -63,7 +63,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, $conf->entity) > 0)
 	{
 		Header("Location: ".$_SERVER["PHP_SELF"]);
@@ -83,21 +83,21 @@ if ($action == 'set')
 }
 elseif ($action == 'specimen')  // For orders
 {
-    $modele=GETPOST('module', 'alpha');
+    $modele = GETPOST('module', 'alpha');
 
     $commande = new CommandeFournisseur($db);
     $commande->initAsSpecimen();
-    $commande->thirdparty=$specimenthirdparty;
+    $commande->thirdparty = $specimenthirdparty;
 
     // Search template files
-    $file=''; $classname=''; $filefound=0;
-    $dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']);
-    foreach($dirmodels as $reldir)
+    $file = ''; $classname = ''; $filefound = 0;
+    $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
+    foreach ($dirmodels as $reldir)
     {
-    	$file=dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0);
+    	$file = dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0);
     	if (file_exists($file))
     	{
-    		$filefound=1;
+    		$filefound = 1;
     		$classname = "pdf_".$modele;
     		break;
     	}
@@ -166,21 +166,21 @@ elseif ($action == 'setdoc')
  * View
  */
 
-$formactions=new FormActions($db);
-$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']);
+$formactions = new FormActions($db);
+$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
 llxHeader();
 
-$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');
 
 
 
-$head=agenda_prepare_head();
+$head = agenda_prepare_head();
 
 dol_fiche_head($head, 'reminders', $langs->trans("Agenda"), -1, 'action');
 
 print '<form action="'.$_SERVER["PHP_SELF"].'" name="agenda">';
-print '<input type="hidden" name="token" value="' . newToken() . '">';
+print '<input type="hidden" name="token" value="'.newToken().'">';
 print '<input type="hidden" name="action" value="set">';
 
 print '<table class="noborder allwidth">'."\n";

+ 15 - 15
htdocs/admin/barcode.php

@@ -89,17 +89,17 @@ elseif ($action == 'update')
 elseif ($action == 'updateengine')
 {
     $sql = "SELECT rowid, coder";
-    $sql.= " FROM ".MAIN_DB_PREFIX."c_barcode_type";
-    $sql.= " WHERE entity = ".$conf->entity;
-    $sql.= " ORDER BY code";
+    $sql .= " FROM ".MAIN_DB_PREFIX."c_barcode_type";
+    $sql .= " WHERE entity = ".$conf->entity;
+    $sql .= " ORDER BY code";
 
-    $resql=$db->query($sql);
+    $resql = $db->query($sql);
     if ($resql)
     {
 	    $num = $db->num_rows($resql);
 	    $i = 0;
 
-	    while ($i <	$num)
+	    while ($i < $num)
 	    {
 	        $obj = $db->fetch_object($resql);
 
@@ -109,12 +109,12 @@ elseif ($action == 'updateengine')
 	            $code_id = $obj->rowid;
 
 	            $sqlp = "UPDATE ".MAIN_DB_PREFIX."c_barcode_type";
-	            $sqlp.= " SET coder = '" . $coder."'";
-	            $sqlp.= " WHERE rowid = ". $code_id;
-	            $sqlp.= " AND entity = ".$conf->entity;
+	            $sqlp .= " SET coder = '".$coder."'";
+	            $sqlp .= " WHERE rowid = ".$code_id;
+	            $sqlp .= " AND entity = ".$conf->entity;
 
-	            $upsql=$db->query($sqlp);
-	            if (! $upsql) dol_print_error($db);
+	            $upsql = $db->query($sqlp);
+	            if (!$upsql) dol_print_error($db);
 	        }
 
 	        $i++;
@@ -209,18 +209,18 @@ print '<td class="center" width="60">'.$langs->trans("CodeBarGenerator").'</td>'
 print "</tr>\n";
 
 $sql = "SELECT rowid, code as encoding, libelle as label, coder, example";
-$sql.= " FROM ".MAIN_DB_PREFIX."c_barcode_type";
-$sql.= " WHERE entity = ".$conf->entity;
-$sql.= " ORDER BY code";
+$sql .= " FROM ".MAIN_DB_PREFIX."c_barcode_type";
+$sql .= " WHERE entity = ".$conf->entity;
+$sql .= " ORDER BY code";
 
 dol_syslog("admin/barcode.php", LOG_DEBUG);
-$resql=$db->query($sql);
+$resql = $db->query($sql);
 if ($resql)
 {
 	$num = $db->num_rows($resql);
 	$i = 0;
 
-	while ($i <	$num)
+	while ($i < $num)
 	{
 		$obj = $db->fetch_object($resql);
 

+ 1 - 1
htdocs/admin/boxes.php

@@ -473,7 +473,7 @@ print '</td>';
 print '</tr>';
 
 // Activate FileCache - Developement
-if ($conf->global->MAIN_FEATURES_LEVEL == 2 || ! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) {
+if ($conf->global->MAIN_FEATURES_LEVEL == 2 || !empty($conf->global->MAIN_ACTIVATE_FILECACHE)) {
     print '<tr class="oddeven"><td width="35%">'.$langs->trans("EnableFileCache").'</td><td>';
     print $form->selectyesno('MAIN_ACTIVATE_FILECACHE', $conf->global->MAIN_ACTIVATE_FILECACHE, 1);
     print '</td>';

+ 36 - 36
htdocs/admin/chequereceipts.php

@@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
 require_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.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();
@@ -51,13 +51,13 @@ if (empty($conf->global->CHEQUERECEIPTS_ADDON)) $conf->global->CHEQUERECEIPTS_AD
 
 if ($action == 'updateMask')
 {
-	$maskconstchequereceipts=GETPOST('maskconstchequereceipts', 'alpha');
-	$maskchequereceipts=GETPOST('maskchequereceipts', 'alpha');
+	$maskconstchequereceipts = GETPOST('maskconstchequereceipts', 'alpha');
+	$maskchequereceipts = GETPOST('maskchequereceipts', 'alpha');
 	if ($maskconstchequereceipts) $res = dolibarr_set_const($db, $maskconstchequereceipts, $maskchequereceipts, 'chaine', 0, '', $conf->entity);
 
-	if (! $res > 0) $error++;
+	if (!$res > 0) $error++;
 
-	if (! $error)
+	if (!$error)
 	{
 		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
 	}
@@ -74,13 +74,13 @@ if ($action == 'setmod')
 
 if ($action == 'set_BANK_CHEQUERECEIPT_FREE_TEXT')
 {
-	$freetext = GETPOST('BANK_CHEQUERECEIPT_FREE_TEXT', 'none');	// No alpha here, we want exact string
+	$freetext = GETPOST('BANK_CHEQUERECEIPT_FREE_TEXT', 'none'); // No alpha here, we want exact string
 
 	$res = dolibarr_set_const($db, "BANK_CHEQUERECEIPT_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
 
-	if (! $res > 0) $error++;
+	if (!$res > 0) $error++;
 
- 	if (! $error)
+ 	if (!$error)
 	{
 		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
 	}
@@ -94,12 +94,12 @@ if ($action == 'set_BANK_CHEQUERECEIPT_FREE_TEXT')
  * View
  */
 
-$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']);
+$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
 llxHeader("", $langs->trans("BankSetupModule"));
 
-$form=new Form($db);
+$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("BankSetupModule"), $linkback, 'title_setup');
 
 $head = bank_admin_prepare_head(null);
@@ -130,25 +130,25 @@ foreach ($dirmodels as $reldir)
 		$handle = opendir($dir);
 		if (is_resource($handle))
 		{
-			while (($file = readdir($handle))!==false)
+			while (($file = readdir($handle)) !== false)
 			{
-				if (! is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS'))
+				if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS'))
 				{
 					$filebis = $file;
-					$name = substr($file, 4, dol_strlen($file) -16);
+					$name = substr($file, 4, dol_strlen($file) - 16);
 					$classname = preg_replace('/\.php$/', '', $file);
 					// For compatibility
-					if (! is_file($dir.$filebis))
+					if (!is_file($dir.$filebis))
 					{
 						$filebis = $file."/".$file.".modules.php";
 						$classname = "mod_chequereceipt_".$file;
 					}
 					// Check if there is a filter on country
 					preg_match('/\-(.*)_(.*)$/', $classname, $reg);
-					if (! empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue;
+					if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue;
 
 					$classname = preg_replace('/\-.*$/', '', $classname);
-					if (! class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis)-3, 3) == 'php')
+					if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php')
 					{
 						// Charging the numbering class
 						require_once $dir.$filebis;
@@ -156,13 +156,13 @@ foreach ($dirmodels as $reldir)
 						$module = new $classname($db);
 
 						// 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())
 						{
 							print '<tr class="oddeven"><td width="100">';
-							print (empty($module->name)?$name:$module->name);
+							print (empty($module->name) ? $name : $module->name);
 							print "</td><td>\n";
 
 							print $module->info();
@@ -171,9 +171,9 @@ foreach ($dirmodels as $reldir)
 
 							// Show example of numbering module
 							print '<td class="nowrap">';
-							$tmp=$module->getExample();
+							$tmp = $module->getExample();
 							if (preg_match('/^Error/', $tmp)) 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";
 
@@ -188,21 +188,21 @@ foreach ($dirmodels as $reldir)
 							}
 							print '</td>';
 
-							$chequereceipts=new RemiseCheque($db);
+							$chequereceipts = new RemiseCheque($db);
 							$chequereceipts->initAsSpecimen();
 
 							// Example
-							$htmltooltip='';
-							$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
-							$nextval=$module->getNextValue($mysoc, $chequereceipts);
+							$htmltooltip = '';
+							$htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
+							$nextval = $module->getNextValue($mysoc, $chequereceipts);
 							if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
-								$htmltooltip.=$langs->trans("NextValue").': ';
+								$htmltooltip .= $langs->trans("NextValue").': ';
 								if ($nextval) {
-									if (preg_match('/^Error/', $nextval) || $nextval=='NotConfigured')
+									if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
 										$nextval = $langs->trans($nextval);
-									$htmltooltip.=$nextval.'<br>';
+									$htmltooltip .= $nextval.'<br>';
 								} else {
-									$htmltooltip.=$langs->trans($module->error).'<br>';
+									$htmltooltip .= $langs->trans($module->error).'<br>';
 								}
 							}
 
@@ -211,7 +211,7 @@ foreach ($dirmodels as $reldir)
 
 							if ($conf->global->CHEQUERECEIPTS_ADDON.'.php' == $file)  // If module is the one used, we show existing errors
 							{
-								if (! empty($module->error)) dol_htmloutput_mesg($module->error, '', 'error', 1);
+								if (!empty($module->error)) dol_htmloutput_mesg($module->error, '', 'error', 1);
 							}
 
 							print '</td>';
@@ -247,15 +247,15 @@ print '<td class="center" width="60">&nbsp;</td>';
 print '<td width="80">&nbsp;</td>';
 print "</tr>\n";
 
-$substitutionarray=pdf_getSubstitutionArray($langs, null, null, 2);
-$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation");
+$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
+$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
 $htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
-foreach($substitutionarray as $key => $val)	$htmltext.=$key.'<br>';
-$htmltext.='</i>';
+foreach ($substitutionarray as $key => $val)	$htmltext .= $key.'<br>';
+$htmltext .= '</i>';
 
 print '<tr class="oddeven"><td colspan="2">';
 print $form->textwithpicto($langs->trans("FreeLegalTextOnChequeReceipts"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
-$variablename='BANK_CHEQUERECEIPT_FREE_TEXT';
+$variablename = 'BANK_CHEQUERECEIPT_FREE_TEXT';
 if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
 {
 	print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
@@ -263,7 +263,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
 else
 {
 	include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
-	$doleditor=new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
+	$doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
 	print $doleditor->Create();
 }
 print '</td><td class="right">';

+ 13 - 13
htdocs/admin/clicktodial.php

@@ -40,8 +40,8 @@ $action = GETPOST('action', 'aZ09');
 
 if ($action == 'setvalue' && $user->admin)
 {
-    $result1=dolibarr_set_const($db, "CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS", GETPOST("CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS"), 'chaine', 0, '', $conf->entity);
-    $result2=dolibarr_set_const($db, "CLICKTODIAL_URL", GETPOST("CLICKTODIAL_URL"), 'chaine', 0, '', $conf->entity);
+    $result1 = dolibarr_set_const($db, "CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS", GETPOST("CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS"), 'chaine', 0, '', $conf->entity);
+    $result2 = dolibarr_set_const($db, "CLICKTODIAL_URL", GETPOST("CLICKTODIAL_URL"), 'chaine', 0, '', $conf->entity);
 
     if ($result1 >= 0 && $result2 >= 0)
     {
@@ -60,10 +60,10 @@ if ($action == 'setvalue' && $user->admin)
 
 $user->fetch_clicktodial();
 
-$wikihelp='EN:Module_ClickToDial_En|FR:Module_ClickToDial|ES:Módulo_ClickTodial_Es';
+$wikihelp = 'EN:Module_ClickToDial_En|FR:Module_ClickToDial|ES:Módulo_ClickTodial_Es';
 llxHeader('', $langs->trans("ClickToDialSetup"), $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("ClickToDialSetup"), $linkback, 'title_setup');
 
 print '<span class="opacitymedium">'.$langs->trans("ClickToDialDesc")."</span><br>\n";
@@ -90,7 +90,7 @@ print '</td></tr>';
 
 print '<tr class="oddeven"><td>';
 print $langs->trans("DefaultLink").'</td><td>';
-print '<input class="quatrevingtpercent" type="text" id="CLICKTODIAL_URL" name="CLICKTODIAL_URL"'.($conf->global->CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS?' disabled="disabled"':'').' value="'.$conf->global->CLICKTODIAL_URL.'"><br>';
+print '<input class="quatrevingtpercent" type="text" id="CLICKTODIAL_URL" name="CLICKTODIAL_URL"'.($conf->global->CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS ? ' disabled="disabled"' : '').' value="'.$conf->global->CLICKTODIAL_URL.'"><br>';
 print ajax_autoselect('CLICKTODIAL_URL');
 print '<br>';
 print $langs->trans("ClickToDialUrlDesc").'<br>';
@@ -111,24 +111,24 @@ print '<div class="center"><br><input type="submit" class="button" value="'.$lan
 print '</form><br><br>';
 
 
-if (! empty($conf->global->CLICKTODIAL_URL))
+if (!empty($conf->global->CLICKTODIAL_URL))
 {
 	$user->fetch_clicktodial();
 
-	$phonefortest=$mysoc->phone;
-	if (GETPOST('phonefortest')) $phonefortest=GETPOST('phonefortest');
+	$phonefortest = $mysoc->phone;
+	if (GETPOST('phonefortest')) $phonefortest = GETPOST('phonefortest');
 
 	print '<form action="'.$_SERVER["PHP_SELF"].'">';
-    print '<input type="hidden" name="token" value="' . newToken() . '">';
+    print '<input type="hidden" name="token" value="'.newToken().'">';
 	print $langs->trans("LinkToTestClickToDial", $user->login).' : ';
 	print '<input class="flat" type="text" name="phonefortest" value="'.dol_escape_htmltag($phonefortest).'">';
 	print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("RefreshPhoneLink")).'">';
 	print '</form>';
 
-	$setupcomplete=1;
-	if (preg_match('/__LOGIN__/', $conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_login)) $setupcomplete=0;
-	if (preg_match('/__PASSWORD__/', $conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_password)) $setupcomplete=0;
-	if (preg_match('/__PHONEFROM__/', $conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_poste)) $setupcomplete=0;
+	$setupcomplete = 1;
+	if (preg_match('/__LOGIN__/', $conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_login)) $setupcomplete = 0;
+	if (preg_match('/__PASSWORD__/', $conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_password)) $setupcomplete = 0;
+	if (preg_match('/__PHONEFROM__/', $conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_poste)) $setupcomplete = 0;
 
 	if ($setupcomplete)
 	{

+ 9 - 9
htdocs/admin/commande_fournisseur_dispatch_extrafields.php

@@ -46,13 +46,13 @@ $extrafields = new ExtraFields($db);
 $form = new Form($db);
 
 // List of supported format
-$tmptype2label=ExtraFields::$type2label;
-$type2label=array('');
-foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val);
+$tmptype2label = ExtraFields::$type2label;
+$type2label = array('');
+foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->trans($val);
 
-$action=GETPOST('action', 'alpha');
-$attrname=GETPOST('attrname', 'alpha');
-$elementtype='commande_fournisseur_dispatch'; //Must be the $table_element of the class that manage extrafield
+$action = GETPOST('action', 'alpha');
+$attrname = GETPOST('attrname', 'alpha');
+$elementtype = 'commande_fournisseur_dispatch'; //Must be the $table_element of the class that manage extrafield
 
 if (!$user->admin) accessforbidden();
 
@@ -69,11 +69,11 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
  * View
  */
 
-$textobject=$langs->transnoentitiesnoconv("Receptions");
+$textobject = $langs->transnoentitiesnoconv("Receptions");
 
 llxHeader('', $langs->trans("ReceptionsSetup"));
 
-$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("ReceptionsSetup"), $linkback, 'title_setup');
 print "<br>\n";
 
@@ -114,7 +114,7 @@ if ($action == 'create')
 /* Edition of an optional field                                               */
 /*                                                                            */
 /* ************************************************************************** */
-if ($action == 'edit' && ! empty($attrname))
+if ($action == 'edit' && !empty($attrname))
 {
 	print "<br>";
 	print load_fiche_titre($langs->trans("FieldEdition", $attrname));

+ 1 - 1
htdocs/admin/company.php

@@ -533,7 +533,7 @@ print '<td class="titlefield">'.$langs->trans("SocialNetworksInformation").'</td
 print "</tr>\n";
 
 $listofnetworks = array('facebook'=>'facebook', 'twitter'=>'twitter', 'linkedin'=>'linkedin', 'instagram'=>'instagram', 'youtube'=>'youtube', 'github'=>'github');
-foreach($listofnetworks as $networkkey => $networkicon) {
+foreach ($listofnetworks as $networkkey => $networkicon) {
 	print '<tr class="oddeven"><td>';
 	print '<label for="'.$networkkey.'url">'.$langs->trans("SocialNetworks".ucfirst($networkkey)."URL").'</label></td><td>';
 	$networkconst = 'MAIN_INFO_SOCIETE_'.strtoupper($networkkey).'_URL';

+ 3 - 3
htdocs/admin/compta.php

@@ -83,7 +83,7 @@ if ($action == 'update')
         }
     }
 
-    if (! $error)
+    if (!$error)
     {
         setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
     }
@@ -99,9 +99,9 @@ if ($action == 'update')
 
 llxHeader();
 
-$form=new Form($db);
+$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('ComptaSetup'), $linkback, 'title_setup');
 
 print '<br>';

+ 5 - 5
htdocs/admin/confexped.php

@@ -35,7 +35,7 @@ $langs->loadLangs(array('admin', 'sendings', 'deliveries'));
 if (!$user->admin)
   accessforbidden();
 
-$action=GETPOST('action', 'alpha');
+$action = GETPOST('action', 'alpha');
 
 
 /*
@@ -43,7 +43,7 @@ $action=GETPOST('action', 'alpha');
  */
 
 // Shipment note
-if (! empty($conf->expedition->enabled) && empty($conf->global->MAIN_SUBMODULE_EXPEDITION))
+if (!empty($conf->expedition->enabled) && empty($conf->global->MAIN_SUBMODULE_EXPEDITION))
 {
 	// This option should always be set to on when module is on.
 	dolibarr_set_const($db, "MAIN_SUBMODULE_EXPEDITION", "1", 'chaine', 0, '', $conf->entity);
@@ -66,7 +66,7 @@ if ($action == 'disable_sending')
 // Delivery note
 if ($action == 'activate_delivery')
 {
-	dolibarr_set_const($db, "MAIN_SUBMODULE_EXPEDITION", "1", 'chaine', 0, '', $conf->entity);    // We must also enable this
+	dolibarr_set_const($db, "MAIN_SUBMODULE_EXPEDITION", "1", 'chaine', 0, '', $conf->entity); // We must also enable this
 	dolibarr_set_const($db, "MAIN_SUBMODULE_LIVRAISON", "1", 'chaine', 0, '', $conf->entity);
 	header("Location: confexped.php");
 	exit;
@@ -84,11 +84,11 @@ elseif ($action == 'disable_delivery')
  */
 
 $dir = DOL_DOCUMENT_ROOT."/core/modules/expedition/";
-$form=new Form($db);
+$form = new Form($db);
 
 llxHeader("", $langs->trans("SendingsSetup"));
 
-$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("SendingsSetup"), $linkback, 'title_setup');
 print '<br>';
 $head = expedition_admin_prepare_head();

+ 46 - 46
htdocs/admin/const.php

@@ -30,22 +30,22 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
 // Load translation files required by the page
 $langs->load("admin");
 
-if (! $user->admin)
+if (!$user->admin)
 	accessforbidden();
 
-$rowid=GETPOST('rowid', 'int');
-$entity=GETPOST('entity', 'int');
-$action=GETPOST('action', 'alpha');
-$update=GETPOST('update', 'alpha');
-$delete=GETPOST('delete', 'none');	// Do not use alpha here
-$debug=GETPOST('debug', 'int');
-$consts=GETPOST('const', 'array');
-$constname=GETPOST('constname', 'alphanohtml');
-$constvalue=GETPOST('constvalue', 'none');	// We shoul dbe able to send everything here
-$constnote=GETPOST('constnote', 'alpha');
+$rowid = GETPOST('rowid', 'int');
+$entity = GETPOST('entity', 'int');
+$action = GETPOST('action', 'alpha');
+$update = GETPOST('update', 'alpha');
+$delete = GETPOST('delete', 'none'); // Do not use alpha here
+$debug = GETPOST('debug', 'int');
+$consts = GETPOST('const', 'array');
+$constname = GETPOST('constname', 'alphanohtml');
+$constvalue = GETPOST('constvalue', 'none'); // We shoul dbe able to send everything here
+$constnote = GETPOST('constnote', '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 = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
@@ -63,7 +63,7 @@ if (empty($sortorder)) $sortorder = 'ASC';
 
 if ($action == 'add' || (GETPOST('add') && $action != 'update'))
 {
-	$error=0;
+	$error = 0;
 
 	if (empty($constname))
 	{
@@ -76,15 +76,15 @@ if ($action == 'add' || (GETPOST('add') && $action != 'update'))
 		$error++;
 	}
 
-	if (! $error)
+	if (!$error)
 	{
 		if (dolibarr_set_const($db, $constname, $constvalue, 'chaine', 1, $constnote, $entity) >= 0)
 		{
 			setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
-			$action="";
-			$constname="";
-			$constvalue="";
-			$constnote="";
+			$action = "";
+			$constname = "";
+			$constvalue = "";
+			$constnote = "";
 		}
 		else
 		{
@@ -94,12 +94,12 @@ if ($action == 'add' || (GETPOST('add') && $action != 'update'))
 }
 
 // Mass update
-if (! empty($consts) && $action == 'update')
+if (!empty($consts) && $action == 'update')
 {
-	$nbmodified=0;
-	foreach($consts as $const)
+	$nbmodified = 0;
+	foreach ($consts as $const)
 	{
-		if (! empty($const["check"]))
+		if (!empty($const["check"]))
 		{
 			if (dolibarr_set_const($db, $const["name"], $const["value"], $const["type"], 1, $const["note"], $const["entity"]) >= 0)
 			{
@@ -112,16 +112,16 @@ if (! empty($consts) && $action == 'update')
 		}
 	}
 	if ($nbmodified > 0) setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
-	$action='';
+	$action = '';
 }
 
 // Mass delete
-if (! empty($consts) && $action == 'delete')
+if (!empty($consts) && $action == 'delete')
 {
-	$nbdeleted=0;
-	foreach($consts as $const)
+	$nbdeleted = 0;
+	foreach ($consts as $const)
 	{
-		if (! empty($const["check"]))	// Is checkbox checked
+		if (!empty($const["check"]))	// Is checkbox checked
 		{
 			if (dolibarr_del_const($db, $const["rowid"], -1) >= 0)
 			{
@@ -134,7 +134,7 @@ if (! empty($consts) && $action == 'delete')
 		}
 	}
 	if ($nbdeleted > 0) setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
-	$action='';
+	$action = '';
 }
 
 // Delete line from delete picto
@@ -157,7 +157,7 @@ if ($action == 'delete')
 
 $form = new Form($db);
 
-$wikihelp='EN:Setup_Other|FR:Paramétrage_Divers|ES:Configuración_Varios';
+$wikihelp = 'EN:Setup_Other|FR:Paramétrage_Divers|ES:Configuración_Varios';
 llxHeader('', $langs->trans("Setup"), $wikihelp);
 
 // Add logic to show/hide buttons
@@ -191,7 +191,7 @@ print "<br>\n";
 
 $param = '';
 
-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">';
 print '<input type="hidden" name="token" value="'.newToken().'">';
 print '<input type="hidden" id="action" name="action" value="">';
 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
@@ -204,7 +204,7 @@ print getTitleFieldOfList('Name', 0, $_SERVER['PHP_SELF'], 'name', '', $param, '
 print getTitleFieldOfList("Value", 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
 print getTitleFieldOfList("Comment", 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
 print getTitleFieldOfList('DateModificationShort', 0, $_SERVER['PHP_SELF'], 'tms', '', $param, '', $sortfield, $sortorder, 'center ')."\n";
-if (! empty($conf->multicompany->enabled) && !$user->entity)
+if (!empty($conf->multicompany->enabled) && !$user->entity)
 {
 	print getTitleFieldOfList('Entity', 0, $_SERVER['PHP_SELF'], 'tms', '', $param, '', $sortfield, $sortorder, 'center ')."\n";
 }
@@ -224,7 +224,7 @@ print '</td>';
 print '<td>';
 print '</td>';
 // Limit to superadmin
-if (! empty($conf->multicompany->enabled) && !$user->entity)
+if (!empty($conf->multicompany->enabled) && !$user->entity)
 {
 	print '<td>';
 	print '<input type="text" class="flat" size="1" name="entity" value="'.$conf->entity.'">';
@@ -243,19 +243,19 @@ print '</tr>';
 
 // Show constants
 $sql = "SELECT";
-$sql.= " rowid";
-$sql.= ", ".$db->decrypt('name')." as name";
-$sql.= ", ".$db->decrypt('value')." as value";
-$sql.= ", type";
-$sql.= ", note";
-$sql.= ", tms";
-$sql.= ", entity";
-$sql.= " FROM ".MAIN_DB_PREFIX."const";
-$sql.= " WHERE entity IN (".$user->entity.",".$conf->entity.")";
+$sql .= " rowid";
+$sql .= ", ".$db->decrypt('name')." as name";
+$sql .= ", ".$db->decrypt('value')." as value";
+$sql .= ", type";
+$sql .= ", note";
+$sql .= ", tms";
+$sql .= ", entity";
+$sql .= " FROM ".MAIN_DB_PREFIX."const";
+$sql .= " WHERE entity IN (".$user->entity.",".$conf->entity.")";
 if ((empty($user->entity) || $user->admin) && $debug) {} 										// to force for superadmin to debug
-elseif (! GETPOST('visible') || GETPOST('visible') != 'all') $sql.= " AND visible = 1";		// We must always have this. Otherwise, array is too large and submitting data fails due to apache POST or GET limits
-if (GETPOST('name')) $sql.=natural_search("name", GETPOST('name'));
-$sql.= $db->order($sortfield, $sortorder);
+elseif (!GETPOST('visible') || GETPOST('visible') != 'all') $sql .= " AND visible = 1"; // We must always have this. Otherwise, array is too large and submitting data fails due to apache POST or GET limits
+if (GETPOST('name')) $sql .= natural_search("name", GETPOST('name'));
+$sql .= $db->order($sortfield, $sortorder);
 
 dol_syslog("Const::listConstant", LOG_DEBUG);
 $result = $db->query($sql);
@@ -291,7 +291,7 @@ if ($result)
 		print '</td>';
 
 		// Entity limit to superadmin
-		if (! empty($conf->multicompany->enabled) && !$user->entity)
+		if (!empty($conf->multicompany->enabled) && !$user->entity)
 		{
 			print '<td>';
 			print '<input type="text" class="flat" size="1" name="const['.$i.'][entity]" value="'.$obj->entity.'">';
@@ -310,7 +310,7 @@ if ($result)
 		}
 		else
 		{
-			print '<a href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&action=delete'.((empty($user->entity) && $debug)?'&debug=1':'').'">'.img_delete().'</a>';
+			print '<a href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&action=delete'.((empty($user->entity) && $debug) ? '&debug=1' : '').'">'.img_delete().'</a>';
 		}
 
 		print "</td></tr>\n";

+ 7 - 7
htdocs/admin/debugbar.php

@@ -32,9 +32,9 @@ global $conf;
 if (!$user->admin) accessforbidden();
 
 // Load translation files required by the page
-$langs->loadLangs(array("admin","other"));
+$langs->loadLangs(array("admin", "other"));
 
-$error=0;
+$error = 0;
 $action = GETPOST('action', 'aZ09');
 
 
@@ -54,7 +54,7 @@ if ($action == 'set')
         $error++;
     }
 
-	if (! $error)
+	if (!$error)
 	{
 		$db->commit();
 		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
@@ -73,14 +73,14 @@ if ($action == 'set')
 
 llxHeader();
 
-$form=new Form($db);
+$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("DebugBarSetup"), $linkback, 'title_setup');
 
 //print load_fiche_titre($langs->trans("DebugBar"));
 
-if (! function_exists('mb_check_encoding'))
+if (!function_exists('mb_check_encoding'))
 {
     $langs->load("errors");
     print info_admin($langs->trans("ErrorPHPNeedModule", 'mbstring'), 0, 0, 'error');
@@ -100,7 +100,7 @@ print '<td class="right"><input type="submit" class="button" '.$option.' value="
 print "</tr>\n";
 
 print '<tr class="oddeven"><td>'.$langs->trans("DEBUGBAR_LOGS_LINES_NUMBER").'</td>';
-print '<td colspan="2"><input type="text" class="flat" name="DEBUGBAR_LOGS_LINES_NUMBER" value="'.(empty($conf->global->DEBUGBAR_LOGS_LINES_NUMBER) ? 250 : $conf->global->DEBUGBAR_LOGS_LINES_NUMBER).'">';   // This slow seriously output
+print '<td colspan="2"><input type="text" class="flat" name="DEBUGBAR_LOGS_LINES_NUMBER" value="'.(empty($conf->global->DEBUGBAR_LOGS_LINES_NUMBER) ? 250 : $conf->global->DEBUGBAR_LOGS_LINES_NUMBER).'">'; // This slow seriously output
 print ' '.$langs->trans("WarningValueHigherSlowsDramaticalyOutput");
 print '</td></tr>';
 

+ 13 - 13
htdocs/admin/delais.php

@@ -134,31 +134,31 @@ $modules = array(
 
 $labelmeteo = array(0=>$langs->trans("No"), 1=>$langs->trans("Yes"), 2=>$langs->trans("OnMobileOnly"));
 
-if (! isset($conf->global->MAIN_DELAY_PROJECT_TO_CLOSE)) {
-	$conf->global->MAIN_DELAY_PROJECT_TO_CLOSE = 7;				// Must be same value than into conf.class.php
+if (!isset($conf->global->MAIN_DELAY_PROJECT_TO_CLOSE)) {
+	$conf->global->MAIN_DELAY_PROJECT_TO_CLOSE = 7; // Must be same value than into conf.class.php
 }
-if (! isset($conf->global->MAIN_DELAY_TASKS_TODO)) {
-	$conf->global->MAIN_DELAY_TASKS_TODO = 7;				// Must be same value than into conf.class.php
+if (!isset($conf->global->MAIN_DELAY_TASKS_TODO)) {
+	$conf->global->MAIN_DELAY_TASKS_TODO = 7; // Must be same value than into conf.class.php
 }
-if (! isset($conf->global->MAIN_DELAY_MEMBERS)) {
-	$conf->global->MAIN_DELAY_MEMBERS = 0;					// Must be same value than into conf.class.php
+if (!isset($conf->global->MAIN_DELAY_MEMBERS)) {
+	$conf->global->MAIN_DELAY_MEMBERS = 0; // Must be same value than into conf.class.php
 }
-if (! isset($conf->global->MAIN_DELAY_ACTIONS_TODO)) {
-	$conf->global->MAIN_DELAY_ACTIONS_TODO = 7;				// Must be same value than into conf.class.php
+if (!isset($conf->global->MAIN_DELAY_ACTIONS_TODO)) {
+	$conf->global->MAIN_DELAY_ACTIONS_TODO = 7; // Must be same value than into conf.class.php
 }
-if (! isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
+if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
 	$conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
 }
-if (! isset($conf->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS)) {
+if (!isset($conf->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS)) {
 	$conf->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS = 7;
 }
-if (! isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
+if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
 	$conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
 }
-if (! isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
+if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
 	$conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
 }
-if (! isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
+if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
 	$conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
 }
 

+ 3 - 3
htdocs/admin/dict.php

@@ -58,7 +58,7 @@ if ($id == 10 && !empty($user->rights->accounting->chartofaccount)) $allowed = 1
 if ($id == 17 && !empty($user->rights->accounting->chartofaccount)) $allowed = 1; // Dictionary with type of expense report and accounting account allowed to manager of chart account
 if (!$allowed) accessforbidden();
 
-$acts =array(); $actl =array();
+$acts = array(); $actl = array();
 $acts[0] = "activate";
 $acts[1] = "disable";
 $actl[0] = img_picto($langs->trans("Disabled"), 'switch_off');
@@ -77,7 +77,7 @@ $pageprev = $page - 1;
 $pagenext = $page + 1;
 
 $search_country_id = GETPOST('search_country_id', 'int');
-if (! GETPOSTISSET('search_country_id') && $search_country_id == '' && ($id == 2 || $id == 3 || $id == 10))	// Not a so good idea to force on current country for all dictionaries. Some tables have entries that are for all countries, we must be able to see them, so this is done for dedicated dictionaries only.
+if (!GETPOSTISSET('search_country_id') && $search_country_id == '' && ($id == 2 || $id == 3 || $id == 10))	// Not a so good idea to force on current country for all dictionaries. Some tables have entries that are for all countries, we must be able to see them, so this is done for dedicated dictionaries only.
 {
 	$search_country_id = $mysoc->country_id;
 }
@@ -445,7 +445,7 @@ $tabcond[16] = (!empty($conf->societe->enabled) && empty($conf->global->SOCIETE_
 $tabcond[17] = (!empty($conf->deplacement->enabled) || !empty($conf->expensereport->enabled));
 $tabcond[18] = !empty($conf->expedition->enabled) || !empty($conf->reception->enabled);
 $tabcond[19] = !empty($conf->societe->enabled);
-$tabcond[20]= (! empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || ! empty($conf->supplier_order->enabled));
+$tabcond[20] = (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled));
 $tabcond[21] = !empty($conf->propal->enabled);
 $tabcond[22] = (!empty($conf->commande->enabled) || !empty($conf->propal->enabled));
 $tabcond[23] = true;

+ 1 - 1
htdocs/admin/dolistore/class/dolistore.class.php

@@ -17,7 +17,7 @@
  */
 
 include_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
-if (! class_exists('PrestaShopWebservice')) // We keep this because some modules add this lib too into a different path. This is to avoid "Cannot declare class PrestaShopWebservice" errors.
+if (!class_exists('PrestaShopWebservice')) // We keep this because some modules add this lib too into a different path. This is to avoid "Cannot declare class PrestaShopWebservice" errors.
 {
     include_once DOL_DOCUMENT_ROOT.'/admin/dolistore/class/PSWebServiceLibrary.class.php';
 }

+ 6 - 6
htdocs/admin/ecm.php

@@ -28,7 +28,7 @@ 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();
 
 
 /*
@@ -36,7 +36,7 @@ if (! $user->admin) accessforbidden();
  */
 if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
 {
-	$code=$reg[1];
+	$code = $reg[1];
 	if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0)
 	{
 		header("Location: ".$_SERVER["PHP_SELF"]);
@@ -50,7 +50,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, $conf->entity) > 0)
 	{
 		header("Location: ".$_SERVER["PHP_SELF"]);
@@ -67,10 +67,10 @@ if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg))
  * View
  */
 
-$help_url='';
+$help_url = '';
 llxHeader('', $langs->trans("ECMSetup"), $help_url);
 
-$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("ECMSetup"), $linkback, 'title_setup');
 print '<br>';
 
@@ -100,7 +100,7 @@ else
 	{
 		print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_ECM_AUTO_TREE_ENABLED">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
 	}
-	elseif(! empty($conf->global->USER_MAIL_REQUIRED))
+	elseif (!empty($conf->global->USER_MAIL_REQUIRED))
 	{
 		print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_ECM_AUTO_TREE_ENABLED">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
 	}

+ 5 - 5
htdocs/admin/emailcollector_card.php

@@ -231,7 +231,7 @@ if ($action == 'confirm_collect')
 $form = new Form($db);
 $formfile = new FormFile($db);
 
-$help_url="EN:Module_EMail_Collector|FR:Module_Collecteur_de_courrier_électronique|ES:Module_EMail_Collector";
+$help_url = "EN:Module_EMail_Collector|FR:Module_Collecteur_de_courrier_électronique|ES:Module_EMail_Collector";
 
 llxHeader('', 'EmailCollector', $help_url);
 
@@ -577,14 +577,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
 	if ($conf->ticket->enabled) $arrayoftypes['ticket'] = 'CreateTicketAndThirdParty';
 
 	// support hook for add action
-	$parameters = array( 'arrayoftypes' => $arrayoftypes ) ;
+	$parameters = array('arrayoftypes' => $arrayoftypes);
 	$res = $hookmanager->executeHooks('addMoreActionsEmailCollector', $parameters, $object, $action);
 
-	if($res)
+	if ($res)
 		$arrayoftypes = $hookmanager->resArray;
 	else
-		foreach($hookmanager->resArray as $k=>$desc)
-			$arrayoftypes[$k]=$desc;
+		foreach ($hookmanager->resArray as $k=>$desc)
+			$arrayoftypes[$k] = $desc;
 
 
 	print $form->selectarray('operationtype', $arrayoftypes, '', 1, 0, 0, '', 1, 0, 0, '', 'maxwidth300');

+ 1 - 1
htdocs/admin/emailcollector_list.php

@@ -170,7 +170,7 @@ if (empty($reshook))
 
 $form = new Form($db);
 
-$help_url="EN:Module_EMail_Collector|FR:Module_Collecteur_de_courrier_électronique|ES:Module_EMail_Collector";
+$help_url = "EN:Module_EMail_Collector|FR:Module_Collecteur_de_courrier_électronique|ES:Module_EMail_Collector";
 $title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("EmailCollector"));
 
 

+ 66 - 66
htdocs/admin/expedition.php

@@ -37,18 +37,18 @@ require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
 // Load translation files required by the page
 $langs->loadLangs(array("admin", "sendings", "deliveries", "other"));
 
-if (! $user->admin)
+if (!$user->admin)
 	accessforbidden();
 
-$action=GETPOST('action', 'alpha');
-$value=GETPOST('value', 'alpha');
+$action = GETPOST('action', 'alpha');
+$value = GETPOST('value', 'alpha');
 $label = GETPOST('label', 'alpha');
 $scandir = GETPOST('scan_dir', 'alpha');
-$type='shipping';
+$type = 'shipping';
 
 if (empty($conf->global->EXPEDITION_ADDON_NUMBER))
 {
-    $conf->global->EXPEDITION_ADDON_NUMBER='mod_expedition_safor';
+    $conf->global->EXPEDITION_ADDON_NUMBER = 'mod_expedition_safor';
 }
 
 
@@ -60,9 +60,9 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
 
 if ($action == 'updateMask')
 {
-	$maskconst=GETPOST('maskconstexpedition', 'alpha');
-	$maskvalue=GETPOST('maskexpedition', 'alpha');
-	if (! empty($maskconst))
+	$maskconst = GETPOST('maskconstexpedition', 'alpha');
+	$maskvalue = GETPOST('maskexpedition', 'alpha');
+	if (!empty($maskconst))
 		$res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity);
 
 	if (isset($res))
@@ -76,7 +76,7 @@ if ($action == 'updateMask')
 
 elseif ($action == 'set_param')
 {
-	$freetext=GETPOST('SHIPPING_FREE_TEXT', 'none');	// No alpha here, we want exact string
+	$freetext = GETPOST('SHIPPING_FREE_TEXT', 'none'); // No alpha here, we want exact string
 	$res = dolibarr_set_const($db, "SHIPPING_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
 	if ($res <= 0)
 	{
@@ -84,7 +84,7 @@ elseif ($action == 'set_param')
 		setEventMessages($langs->trans("Error"), null, 'errors');
 	}
 
-	$draft=GETPOST('SHIPPING_DRAFT_WATERMARK', 'alpha');
+	$draft = GETPOST('SHIPPING_DRAFT_WATERMARK', 'alpha');
 	$res = dolibarr_set_const($db, "SHIPPING_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
 	if ($res <= 0)
 	{
@@ -92,7 +92,7 @@ elseif ($action == 'set_param')
 		setEventMessages($langs->trans("Error"), null, 'errors');
 	}
 
-	if (! $error)
+	if (!$error)
 	{
 		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
 	}
@@ -100,20 +100,20 @@ elseif ($action == 'set_param')
 
 elseif ($action == 'specimen')
 {
-	$modele=GETPOST('module', 'alpha');
+	$modele = GETPOST('module', 'alpha');
 
 	$exp = new Expedition($db);
 	$exp->initAsSpecimen();
 
 	// Search template files
-	$file=''; $classname=''; $filefound=0;
-	$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']);
-	foreach($dirmodels as $reldir)
+	$file = ''; $classname = ''; $filefound = 0;
+	$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
+	foreach ($dirmodels as $reldir)
 	{
-	    $file=dol_buildpath($reldir."core/modules/expedition/doc/pdf_".$modele.".modules.php", 0);
+	    $file = dol_buildpath($reldir."core/modules/expedition/doc/pdf_".$modele.".modules.php", 0);
 		if (file_exists($file))
 		{
-			$filefound=1;
+			$filefound = 1;
 			$classname = "pdf_".$modele;
 			break;
 		}
@@ -186,13 +186,13 @@ elseif ($action == 'setmodel')
  * View
  */
 
-$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']);
+$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
 
-$form=new Form($db);
+$form = new Form($db);
 
 llxHeader("", $langs->trans("SendingsSetup"));
 
-$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("SendingsSetup"), $linkback, 'title_setup');
 print '<br>';
 $head = expedition_admin_prepare_head();
@@ -223,11 +223,11 @@ foreach ($dirmodels as $reldir)
 		$handle = opendir($dir);
 		if (is_resource($handle))
 		{
-			while (($file = readdir($handle))!==false)
+			while (($file = readdir($handle)) !== false)
 			{
-				if (substr($file, 0, 15) == 'mod_expedition_' && substr($file, dol_strlen($file)-3, 3) == 'php')
+				if (substr($file, 0, 15) == 'mod_expedition_' && substr($file, dol_strlen($file) - 3, 3) == 'php')
 				{
-					$file = substr($file, 0, dol_strlen($file)-4);
+					$file = substr($file, 0, dol_strlen($file) - 4);
 
 					require_once $dir.$file.'.php';
 
@@ -236,7 +236,7 @@ foreach ($dirmodels as $reldir)
 					if ($module->isEnabled())
 					{
 						// 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;
 
 						print '<tr><td>'.$module->nom."</td>\n";
@@ -246,11 +246,11 @@ foreach ($dirmodels as $reldir)
 
                         // 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";
 
@@ -267,21 +267,21 @@ foreach ($dirmodels as $reldir)
 						}
 						print '</td>';
 
-						$expedition=new Expedition($db);
+						$expedition = new Expedition($db);
 						$expedition->initAsSpecimen();
 
 						// Info
-						$htmltooltip='';
-						$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
-						$nextval=$module->getNextValue($mysoc, $expedition);
+						$htmltooltip = '';
+						$htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
+						$nextval = $module->getNextValue($mysoc, $expedition);
                         if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
-                            $htmltooltip.=''.$langs->trans("NextValue").': ';
+                            $htmltooltip .= ''.$langs->trans("NextValue").': ';
                             if ($nextval) {
-                                if (preg_match('/^Error/', $nextval) || $nextval=='NotConfigured')
+                                if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
                                     $nextval = $langs->trans($nextval);
-                                $htmltooltip.=$nextval.'<br>';
+                                $htmltooltip .= $nextval.'<br>';
                             } else {
-                                $htmltooltip.=$langs->trans($module->error).'<br>';
+                                $htmltooltip .= $langs->trans($module->error).'<br>';
                             }
                         }
 
@@ -307,19 +307,19 @@ print '</table><br>';
 print load_fiche_titre($langs->trans("SendingsReceiptModel"), '', '');
 
 // Defini tableau def de modele invoice
-$type="shipping";
+$type = "shipping";
 $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);
+$resql = $db->query($sql);
 if ($resql)
 {
 	$i = 0;
-	$num_rows=$db->num_rows($resql);
+	$num_rows = $db->num_rows($resql);
 	while ($i < $num_rows)
 	{
 		$array = $db->fetch_array($resql);
@@ -346,42 +346,42 @@ clearstatcache();
 
 foreach ($dirmodels as $reldir)
 {
-    foreach (array('','/doc') as $valdir)
+    foreach (array('', '/doc') as $valdir)
     {
     	$dir = dol_buildpath($reldir."core/modules/expedition".$valdir);
 
         if (is_dir($dir))
         {
-            $handle=opendir($dir);
+            $handle = opendir($dir);
             if (is_resource($handle))
             {
-                while (($file = readdir($handle))!==false)
+                while (($file = readdir($handle)) !== false)
                 {
-                    $filelist[]=$file;
+                    $filelist[] = $file;
                 }
                 closedir($handle);
                 arsort($filelist);
 
-                foreach($filelist as $file)
+                foreach ($filelist as $file)
                 {
                     if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
                     {
                     	if (file_exists($dir.'/'.$file))
                     	{
-                    		$name = substr($file, 4, dol_strlen($file) -16);
-	                        $classname = substr($file, 0, dol_strlen($file) -12);
+                    		$name = substr($file, 4, dol_strlen($file) - 16);
+	                        $classname = substr($file, 0, dol_strlen($file) - 12);
 
 	                        require_once $dir.'/'.$file;
 	                        $module = new $classname($db);
 
-	                        $modulequalified=1;
-	                        if ($module->version == 'development'  && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0;
-	                        if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0;
+	                        $modulequalified = 1;
+	                        if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
+	                        if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0;
 
 	                        if ($modulequalified)
 	                        {
 	                            print '<tr><td width="100">';
-	                            print (empty($module->name)?$name:$module->name);
+	                            print (empty($module->name) ? $name : $module->name);
 	                            print "</td><td>\n";
 	                            if (method_exists($module, 'info')) print $module->info($langs);
 	                            else print $module->description;
@@ -416,18 +416,18 @@ foreach ($dirmodels as $reldir)
 	                            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>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1);
-					    		$htmltooltip.='<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
-					    		$htmltooltip.='<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
-					    		$htmltooltip.='<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1);
+					    		$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
+					    		$htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
+					    		$htmltooltip .= '<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1);
+					    		$htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
+					    		$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
+					    		$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1);
 
 	                            print '<td class="center">';
 	                            print $form->textwithpicto('', $htmltooltip, 1, 0);
@@ -474,15 +474,15 @@ print "<tr class=\"liste_titre\">";
 print "<td>".$langs->trans("Parameter")."</td>\n";
 print "</tr>";
 
-$substitutionarray=pdf_getSubstitutionArray($langs, null, null, 2);
-$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation");
+$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
+$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
 $htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
-foreach($substitutionarray as $key => $val)	$htmltext.=$key.'<br>';
-$htmltext.='</i>';
+foreach ($substitutionarray as $key => $val)	$htmltext .= $key.'<br>';
+$htmltext .= '</i>';
 
 print '<tr><td>';
 print $form->textwithpicto($langs->trans("FreeLegalTextOnShippings"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
-$variablename='SHIPPING_FREE_TEXT';
+$variablename = 'SHIPPING_FREE_TEXT';
 if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
 {
     print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
@@ -490,7 +490,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
 else
 {
     include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
-    $doleditor=new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
+    $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
     print $doleditor->Create();
 }
 print "</td></tr>\n";

+ 9 - 9
htdocs/admin/expedition_extrafields.php

@@ -43,13 +43,13 @@ $extrafields = new ExtraFields($db);
 $form = new Form($db);
 
 // List of supported format
-$tmptype2label=ExtraFields::$type2label;
-$type2label=array('');
-foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
+$tmptype2label = ExtraFields::$type2label;
+$type2label = array('');
+foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val);
 
-$action=GETPOST('action', 'alpha');
-$attrname=GETPOST('attrname', 'alpha');
-$elementtype='expedition'; //Must be the $table_element of the class that manage extrafield
+$action = GETPOST('action', 'alpha');
+$attrname = GETPOST('attrname', 'alpha');
+$elementtype = 'expedition'; //Must be the $table_element of the class that manage extrafield
 
 if (!$user->admin) accessforbidden();
 
@@ -66,11 +66,11 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
  * View
  */
 
-$textobject=$langs->transnoentitiesnoconv("Sendings");
+$textobject = $langs->transnoentitiesnoconv("Sendings");
 
 llxHeader('', $langs->trans("SendingsSetup"));
 
-$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("SendingsSetup"), $linkback, 'title_setup');
 print "<br>\n";
 
@@ -111,7 +111,7 @@ if ($action == 'create')
 /* Edition of an optional field                                                */
 /*                                                                            */
 /* ************************************************************************** */
-if ($action == 'edit' && ! empty($attrname))
+if ($action == 'edit' && !empty($attrname))
 {
 	print "<br>";
 	print load_fiche_titre($langs->trans("FieldEdition", $attrname));

+ 9 - 9
htdocs/admin/expeditiondet_extrafields.php

@@ -44,13 +44,13 @@ $extrafields = new ExtraFields($db);
 $form = new Form($db);
 
 // List of supported format
-$tmptype2label=ExtraFields::$type2label;
-$type2label=array('');
-foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
+$tmptype2label = ExtraFields::$type2label;
+$type2label = array('');
+foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val);
 
-$action=GETPOST('action', 'alpha');
-$attrname=GETPOST('attrname', 'alpha');
-$elementtype='expeditiondet'; //Must be the $table_element of the class that manage extrafield
+$action = GETPOST('action', 'alpha');
+$attrname = GETPOST('attrname', 'alpha');
+$elementtype = 'expeditiondet'; //Must be the $table_element of the class that manage extrafield
 
 if (!$user->admin) accessforbidden();
 
@@ -67,11 +67,11 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
  * View
  */
 
-$textobject=$langs->transnoentitiesnoconv("Sendings");
+$textobject = $langs->transnoentitiesnoconv("Sendings");
 
 llxHeader('', $langs->trans("SendingsSetup"));
 
-$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("SendingsSetup"), $linkback, 'title_setup');
 print "<br>\n";
 
@@ -112,7 +112,7 @@ if ($action == 'create')
 /* Edition of an optional field                                               */
 /*                                                                            */
 /* ************************************************************************** */
-if ($action == 'edit' && ! empty($attrname))
+if ($action == 'edit' && !empty($attrname))
 {
     print "<br>";
     print load_fiche_titre($langs->trans("FieldEdition", $attrname));

+ 61 - 61
htdocs/admin/expensereport.php

@@ -37,13 +37,13 @@ require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
 // Load translation files required by the page
 $langs->loadLangs(array('admin', 'errors', 'trips', 'other'));
 
-if (! $user->admin) accessforbidden();
+if (!$user->admin) accessforbidden();
 
 $action = GETPOST('action', 'alpha');
 $value = GETPOST('value', 'alpha');
 $label = GETPOST('label', 'alpha');
 $scandir = GETPOST('scan_dir', 'alpha');
-$type='expensereport';
+$type = 'expensereport';
 
 
 /*
@@ -54,13 +54,13 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
 
 if ($action == 'updateMask')
 {
-	$maskconst=GETPOST('maskconst', 'alpha');
-	$maskvalue=GETPOST('maskvalue', 'alpha');
+	$maskconst = GETPOST('maskconst', 'alpha');
+	$maskvalue = GETPOST('maskvalue', 'alpha');
 	if ($maskconst) $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity);
 
-	if (! $res > 0) $error++;
+	if (!$res > 0) $error++;
 
- 	if (! $error)
+ 	if (!$error)
     {
         setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
     }
@@ -72,22 +72,22 @@ if ($action == 'updateMask')
 
 elseif ($action == 'specimen') // For fiche inter
 {
-	$modele= GETPOST('module', 'alpha');
+	$modele = GETPOST('module', 'alpha');
 
 	$inter = new ExpenseReport($db);
 	$inter->initAsSpecimen();
-	$inter->status = 0;     // Force statut draft to show watermark
-	$inter->fk_statut = 0;     // Force statut draft to show watermark
+	$inter->status = 0; // Force statut draft to show watermark
+	$inter->fk_statut = 0; // Force statut draft to show watermark
 
 	// Search template files
-	$file=''; $classname=''; $filefound=0;
-	$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']);
-	foreach($dirmodels as $reldir)
+	$file = ''; $classname = ''; $filefound = 0;
+	$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
+	foreach ($dirmodels as $reldir)
 	{
-	    $file=dol_buildpath($reldir."core/modules/expensereport/doc/pdf_".$modele.".modules.php", 0);
+	    $file = dol_buildpath($reldir."core/modules/expensereport/doc/pdf_".$modele.".modules.php", 0);
 		if (file_exists($file))
 		{
-			$filefound=1;
+			$filefound = 1;
 			$classname = "pdf_".$modele;
 			break;
 		}
@@ -166,15 +166,15 @@ elseif ($action == 'setoptions')
 {
     $db->begin();
 
-	$freetext= GETPOST('EXPENSEREPORT_FREE_TEXT', 'none');	// No alpha here, we want exact string
+	$freetext = GETPOST('EXPENSEREPORT_FREE_TEXT', 'none'); // No alpha here, we want exact string
 	$res1 = dolibarr_set_const($db, "EXPENSEREPORT_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
 
-	$draft= GETPOST('EXPENSEREPORT_DRAFT_WATERMARK', 'alpha');
+	$draft = GETPOST('EXPENSEREPORT_DRAFT_WATERMARK', 'alpha');
 	$res2 = dolibarr_set_const($db, "EXPENSEREPORT_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
 
-	if (! $res1 > 0 || ! $res2 > 0) $error++;
+	if (!$res1 > 0 || !$res2 > 0) $error++;
 
- 	if (! $error)
+ 	if (!$error)
     {
         $db->commit();
         setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
@@ -191,17 +191,17 @@ elseif ($action == 'setoptions')
  * View
  */
 
-$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']);
+$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
 
 llxHeader('', $langs->trans("ExpenseReportsSetup"));
 
-$form=new Form($db);
+$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("ExpenseReportsSetup"), $linkback, 'title_setup');
 
 
-$head=expensereport_admin_prepare_head();
+$head = expensereport_admin_prepare_head();
 
 dol_fiche_head($head, 'expensereport', $langs->trans("ExpenseReports"), -1, 'trip');
 
@@ -231,18 +231,18 @@ foreach ($dirmodels as $reldir)
 		$handle = opendir($dir);
 		if (is_resource($handle))
 		{
-			while (($file = readdir($handle))!==false)
+			while (($file = readdir($handle)) !== false)
 			{
-				if (substr($file, 0, 18) == 'mod_expensereport_' && substr($file, dol_strlen($file)-3, 3) == 'php')
+				if (substr($file, 0, 18) == 'mod_expensereport_' && substr($file, dol_strlen($file) - 3, 3) == 'php')
 				{
-					$file = substr($file, 0, dol_strlen($file)-4);
+					$file = substr($file, 0, dol_strlen($file) - 4);
 
 					require_once $dir.$file.'.php';
 
 					$module = new $file($db);
 
 					// 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())
@@ -253,9 +253,9 @@ foreach ($dirmodels as $reldir)
 
                         // Show example of numbering model
                         print '<td class="nowrap">';
-                        $tmp=$module->getExample();
+                        $tmp = $module->getExample();
                         if (preg_match('/^Error/', $tmp)) 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";
 
@@ -272,21 +272,21 @@ foreach ($dirmodels as $reldir)
 						}
 						print '</td>';
 
-						$exp=new ExpenseReport($db);
+						$exp = new ExpenseReport($db);
 						$exp->initAsSpecimen();
 
 						// Info
-						$htmltooltip='';
-						$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
-						$nextval=$module->getNextValue($exp);
+						$htmltooltip = '';
+						$htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
+						$nextval = $module->getNextValue($exp);
                         if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
-                            $htmltooltip.=''.$langs->trans("NextValue").': ';
+                            $htmltooltip .= ''.$langs->trans("NextValue").': ';
                             if ($nextval) {
-                                if (preg_match('/^Error/', $nextval) || $nextval=='NotConfigured')
+                                if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
                                     $nextval = $langs->trans($nextval);
-                                $htmltooltip.=$nextval.'<br>';
+                                $htmltooltip .= $nextval.'<br>';
                             } else {
-                                $htmltooltip.=$langs->trans($module->error).'<br>';
+                                $htmltooltip .= $langs->trans($module->error).'<br>';
                             }
                         }
 
@@ -311,17 +311,17 @@ print "</table><br>\n";
 print load_fiche_titre($langs->trans("TemplatePDFExpenseReports"), '', '');
 
 // Defini tableau def des modeles
-$type='expensereport';
+$type = 'expensereport';
 $def = array();
 $sql = "SELECT nom";
-$sql.= " FROM ".MAIN_DB_PREFIX."document_model";
-$sql.= " WHERE type = '".$type."'";
-$sql.= " AND entity = ".$conf->entity;
-$resql=$db->query($sql);
+$sql .= " FROM ".MAIN_DB_PREFIX."document_model";
+$sql .= " WHERE type = '".$type."'";
+$sql .= " AND entity = ".$conf->entity;
+$resql = $db->query($sql);
 if ($resql)
 {
 	$i = 0;
-	$num_rows=$db->num_rows($resql);
+	$num_rows = $db->num_rows($resql);
 	while ($i < $num_rows)
 	{
 		$array = $db->fetch_array($resql);
@@ -352,17 +352,17 @@ foreach ($dirmodels as $reldir)
 
 	if (is_dir($dir))
 	{
-		$handle=opendir($dir);
+		$handle = opendir($dir);
 		if (is_resource($handle))
 		{
-			while (($file = readdir($handle))!==false)
+			while (($file = readdir($handle)) !== false)
 			{
-				$filelist[]=$file;
+				$filelist[] = $file;
 			}
 			closedir($handle);
 			arsort($filelist);
 
-			foreach($filelist as $file)
+			foreach ($filelist as $file)
 			{
 				if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
 		    	{
@@ -416,15 +416,15 @@ foreach ($dirmodels as $reldir)
 		    				print '</td>';
 
 		    				// Info
-		    				$htmltooltip =    ''.$langs->trans("Name").': '.$module->name;
-		    				$htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
-		    				$htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
-		    				$htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
-		    				$htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
-		    				$htmltooltip.='<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1);
-		    				$htmltooltip.='<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
-		    				$htmltooltip.='<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
-		    				$htmltooltip.='<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1);
+		    				$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
+		    				$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
+		    				$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
+		    				$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
+		    				$htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
+		    				$htmltooltip .= '<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1);
+		    				$htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
+		    				$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
+		    				$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1);
 		    				print '<td class="center">';
 		    				print $form->textwithpicto('', $htmltooltip, -1, 0);
 		    				print '</td>';
@@ -472,15 +472,15 @@ print '<td>'.$langs->trans("Parameter").'</td>';
 print '<td class="center" width="60"></td>';
 print "</tr>\n";
 
-$substitutionarray=pdf_getSubstitutionArray($langs, null, null, 2);
-$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation");
+$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
+$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
 $htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
-foreach($substitutionarray as $key => $val)	$htmltext.=$key.'<br>';
-$htmltext.='</i>';
+foreach ($substitutionarray as $key => $val)	$htmltext .= $key.'<br>';
+$htmltext .= '</i>';
 
 print '<tr class="oddeven"><td colspan="2">';
 print $form->textwithpicto($langs->trans("FreeLegalTextOnExpenseReports"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
-$variablename='EXPENSEREPORT_FREE_TEXT';
+$variablename = 'EXPENSEREPORT_FREE_TEXT';
 if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
 {
     print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
@@ -488,7 +488,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
 else
 {
     include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
-    $doleditor=new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
+    $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
     print $doleditor->Create();
 }
 print '</td></tr>'."\n";

+ 8 - 8
htdocs/admin/expensereport_extrafields.php

@@ -40,13 +40,13 @@ $extrafields = new ExtraFields($db);
 $form = new Form($db);
 
 // List of supported format
-$tmptype2label=ExtraFields::$type2label;
-$type2label=array('');
-foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
+$tmptype2label = ExtraFields::$type2label;
+$type2label = array('');
+foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val);
 
-$action=GETPOST('action', 'alpha');
-$attrname=GETPOST('attrname', 'alpha');
-$elementtype='expensereport'; //Must be the $table_element of the class that manage extrafield
+$action = GETPOST('action', 'alpha');
+$attrname = GETPOST('attrname', 'alpha');
+$elementtype = 'expensereport'; //Must be the $table_element of the class that manage extrafield
 
 if (!$user->admin) accessforbidden();
 
@@ -65,7 +65,7 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
 
 llxHeader('', $langs->trans("ExpenseReportsSetup"));
 
-$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("ExpenseReportsSetup"), $linkback, 'title_setup');
 
 $head = expensereport_admin_prepare_head();
@@ -105,7 +105,7 @@ if ($action == 'create')
 /* Edition of an optional field                                               */
 /*                                                                            */
 /* ************************************************************************** */
-if ($action == 'edit' && ! empty($attrname))
+if ($action == 'edit' && !empty($attrname))
 {
 	print "<br>";
 	print load_fiche_titre($langs->trans("FieldEdition", $attrname));

+ 6 - 6
htdocs/admin/expensereport_ik.php

@@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
 require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport_ik.class.php';
 
 // Load translation files required by the page
-$langs->loadLangs(array("admin","trips","errors","other","dict"));
+$langs->loadLangs(array("admin", "trips", "errors", "other", "dict"));
 
 if (!$user->admin) accessforbidden();
 
@@ -88,12 +88,12 @@ $rangesbycateg = ExpenseReportIk::getAllRanges();
 
 llxHeader('', $langs->trans("ExpenseReportsSetup"));
 
-$form=new Form($db);
+$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("ExpenseReportsIkSetup"), $linkback, 'title_setup');
 
-$head=expensereport_admin_prepare_head();
+$head = expensereport_admin_prepare_head();
 dol_fiche_head($head, 'expenseik', $langs->trans("ExpenseReportsIk"), -1, 'trip');
 
 echo $langs->trans('ExpenseReportIkDesc');
@@ -125,11 +125,11 @@ foreach ($rangesbycateg as $fk_c_exp_tax_cat => $Tab)
 
 	if ($Tab['active'] == 0) continue;
 
-	$tranche=1;
+	$tranche = 1;
 
 	foreach ($Tab['ranges'] as $k => $range)
 	{
-		if (isset($Tab['ranges'][$k+1])) $label = $langs->trans('expenseReportRangeFromTo', $range->range_ik, ($Tab['ranges'][$k+1]->range_ik-1));
+		if (isset($Tab['ranges'][$k + 1])) $label = $langs->trans('expenseReportRangeFromTo', $range->range_ik, ($Tab['ranges'][$k + 1]->range_ik - 1));
 		else $label = $langs->trans('expenseReportRangeMoreThan', $range->range_ik);
 
 		if ($range->range_active == 0) $label = $form->textwithpicto($label, $langs->trans('expenseReportRangeDisabled'), 1, 'help', '', 0, 3);

+ 44 - 44
htdocs/admin/external_rss.php

@@ -38,8 +38,8 @@ $langs->load("admin");
 if (!$user->admin) accessforbidden();
 
 $def = array();
-$lastexternalrss=0;
-$action=GETPOST('action', 'aZ09');
+$lastexternalrss = 0;
+$action = GETPOST('action', 'aZ09');
 
 
 /*
@@ -47,10 +47,10 @@ $action=GETPOST('action', 'aZ09');
  */
 
 // positionne la variable pour le nombre de rss externes
-$sql ="SELECT ".$db->decrypt('name')." as name FROM ".MAIN_DB_PREFIX."const";
-$sql.=" WHERE ".$db->decrypt('name')." LIKE 'EXTERNAL_RSS_URLRSS_%'";
+$sql = "SELECT ".$db->decrypt('name')." as name FROM ".MAIN_DB_PREFIX."const";
+$sql .= " WHERE ".$db->decrypt('name')." LIKE 'EXTERNAL_RSS_URLRSS_%'";
 //print $sql;
-$result=$db->query($sql);	// We can't use SELECT MAX() because EXTERNAL_RSS_URLRSS_10 is lower than EXTERNAL_RSS_URLRSS_9
+$result = $db->query($sql); // We can't use SELECT MAX() because EXTERNAL_RSS_URLRSS_10 is lower than EXTERNAL_RSS_URLRSS_9
 if ($result)
 {
     while ($obj = $db->fetch_object($result))
@@ -66,12 +66,12 @@ else
 
 if ($action == 'add' || GETPOST("modify"))
 {
-    $external_rss_title = "external_rss_title_" . GETPOST("norss", 'int');
-    $external_rss_urlrss = "external_rss_urlrss_" . GETPOST("norss", 'int');
+    $external_rss_title = "external_rss_title_".GETPOST("norss", 'int');
+    $external_rss_urlrss = "external_rss_urlrss_".GETPOST("norss", 'int');
 
-    if (! empty($_POST[$external_rss_urlrss]))
+    if (!empty($_POST[$external_rss_urlrss]))
     {
-        $boxlabel='(ExternalRSSInformations)';
+        $boxlabel = '(ExternalRSSInformations)';
         //$external_rss_url = "external_rss_url_" . $_POST["norss"];
 
         $db->begin();
@@ -95,16 +95,16 @@ if ($action == 'add' || GETPOST("modify"))
 		{
 			// Ajoute boite box_external_rss dans definition des boites
 	        $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes_def (file, note)";
-			$sql.= " VALUES ('box_external_rss.php','".$db->escape(GETPOST("norss", 'int').' ('.GETPOST($external_rss_title, 'alpha')).")')";
-	        if (! $db->query($sql))
+			$sql .= " VALUES ('box_external_rss.php','".$db->escape(GETPOST("norss", 'int').' ('.GETPOST($external_rss_title, 'alpha')).")')";
+	        if (!$db->query($sql))
 	        {
 	        	dol_print_error($db);
 	            $err++;
 	        }
 		}
 
-		$result1=dolibarr_set_const($db, "EXTERNAL_RSS_TITLE_" . GETPOST("norss", 'int'), GETPOST($external_rss_title, 'alpha'), 'chaine', 0, '', $conf->entity);
-		if ($result1) $result2=dolibarr_set_const($db, "EXTERNAL_RSS_URLRSS_" . GETPOST("norss", 'int'), GETPOST($external_rss_urlrss, 'alpha'), 'chaine', 0, '', $conf->entity);
+		$result1 = dolibarr_set_const($db, "EXTERNAL_RSS_TITLE_".GETPOST("norss", 'int'), GETPOST($external_rss_title, 'alpha'), 'chaine', 0, '', $conf->entity);
+		if ($result1) $result2 = dolibarr_set_const($db, "EXTERNAL_RSS_URLRSS_".GETPOST("norss", 'int'), GETPOST($external_rss_urlrss, 'alpha'), 'chaine', 0, '', $conf->entity);
 
         if ($result1 && $result2)
         {
@@ -128,27 +128,27 @@ if ($_POST["delete"])
 
 		// Supprime boite box_external_rss de definition des boites
         $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."boxes_def";
-        $sql.= " WHERE file = 'box_external_rss.php' AND note LIKE '".$db->escape(GETPOST("norss", 'int'))." %'";
+        $sql .= " WHERE file = 'box_external_rss.php' AND note LIKE '".$db->escape(GETPOST("norss", 'int'))." %'";
 
-		$resql=$db->query($sql);
+		$resql = $db->query($sql);
 		if ($resql)
         {
 			$num = $db->num_rows($resql);
-			$i=0;
+			$i = 0;
 			while ($i < $num)
 			{
-				$obj=$db->fetch_object($resql);
+				$obj = $db->fetch_object($resql);
 
 		        $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes";
-		        $sql.= " WHERE entity = ".$conf->entity;
-		        $sql.= " AND box_id = ".$obj->rowid;
-				$resql=$db->query($sql);
+		        $sql .= " WHERE entity = ".$conf->entity;
+		        $sql .= " AND box_id = ".$obj->rowid;
+				$resql = $db->query($sql);
 
 		        $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes_def";
-		        $sql.= " WHERE rowid = ".$obj->rowid;
-				$resql=$db->query($sql);
+		        $sql .= " WHERE rowid = ".$obj->rowid;
+				$resql = $db->query($sql);
 
-				if (! $resql)
+				if (!$resql)
 				{
 					$db->rollback();
 					dol_print_error($db, "sql=".$sql);
@@ -168,8 +168,8 @@ if ($_POST["delete"])
         }
 
 
-		$result1=dolibarr_del_const($db, "EXTERNAL_RSS_TITLE_".GETPOST("norss", 'int'), $conf->entity);
-		if ($result1) $result2=dolibarr_del_const($db, "EXTERNAL_RSS_URLRSS_".GETPOST("norss", 'int'), $conf->entity);
+		$result1 = dolibarr_del_const($db, "EXTERNAL_RSS_TITLE_".GETPOST("norss", 'int'), $conf->entity);
+		if ($result1) $result2 = dolibarr_del_const($db, "EXTERNAL_RSS_URLRSS_".GETPOST("norss", 'int'), $conf->entity);
 
         if ($result1 && $result2)
         {
@@ -192,7 +192,7 @@ if ($_POST["delete"])
 
 llxHeader('', $langs->trans("ExternalRSSSetup"));
 
-$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("ExternalRSSSetup"), $linkback, 'title_setup');
 print '<br>';
 
@@ -207,13 +207,13 @@ print '<td>'.$langs->trans("Example").'</td>';
 print '</tr>';
 print '<tr class="impair">';
 print '<td width="100">'.$langs->trans("Title").'</td>';
-print '<td><input type="text" class="flat minwidth300" name="external_rss_title_'.($lastexternalrss+1).'" value=""></td>';
+print '<td><input type="text" class="flat minwidth300" name="external_rss_title_'.($lastexternalrss + 1).'" value=""></td>';
 print '<td>'.$langs->trans('RSSUrlExample').'</td>';
 print '</tr>';
 
 print '<tr class="pair">';
 print '<td>'.$langs->trans('RSSUrl').'</td>';
-print '<td><input type="text" class="flat minwidth300" name="external_rss_urlrss_'.($lastexternalrss+1).'" value=""></td>';
+print '<td><input type="text" class="flat minwidth300" name="external_rss_urlrss_'.($lastexternalrss + 1).'" value=""></td>';
 print '<td>http://news.google.com/news?ned=us&topic=h&output=rss<br>http://www.dolibarr.org/rss</td>';
 print '</tr>';
 print '</table>';
@@ -221,22 +221,22 @@ print '</table>';
 print '<br><div class="center">';
 print '<input type="submit" class="button" value="'.$langs->trans("Add").'">';
 print '<input type="hidden" name="action" value="add">';
-print '<input type="hidden" name="norss" value="'.($lastexternalrss+1).'">';
+print '<input type="hidden" name="norss" value="'.($lastexternalrss + 1).'">';
 print '</div><br><br>';
 
 print '</form>';
 
 
-$sql ="SELECT rowid, file, note FROM ".MAIN_DB_PREFIX."boxes_def";
-$sql.=" WHERE file = 'box_external_rss.php'";
-$sql.=" ORDER BY note";
+$sql = "SELECT rowid, file, note FROM ".MAIN_DB_PREFIX."boxes_def";
+$sql .= " WHERE file = 'box_external_rss.php'";
+$sql .= " ORDER BY note";
 
 dol_syslog("select rss boxes", LOG_DEBUG);
-$resql=$db->query($sql);
+$resql = $db->query($sql);
 if ($resql)
 {
-	$num =$db->num_rows($resql);
-	$i=0;
+	$num = $db->num_rows($resql);
+	$i = 0;
 
 	while ($i < $num)
 	{
@@ -244,11 +244,11 @@ if ($resql)
 
 		preg_match('/^([0-9]+)/i', $obj->note, $reg);
 		$idrss = $reg[1];
-		$keyrsstitle="EXTERNAL_RSS_TITLE_".$idrss;
-		$keyrssurl="EXTERNAL_RSS_URLRSS_".$idrss;
+		$keyrsstitle = "EXTERNAL_RSS_TITLE_".$idrss;
+		$keyrssurl = "EXTERNAL_RSS_URLRSS_".$idrss;
         //print "x".$idrss;
 
-        $rssparser=new RssParser($db);
+        $rssparser = new RssParser($db);
 		$result = $rssparser->parser($conf->global->$keyrssurl, 5, 300, $conf->externalrss->dir_temp);
 
 		print "<br>";
@@ -258,7 +258,7 @@ if ($resql)
 		print '<input type="hidden" name="token" value="'.newToken().'">';
 
 		print "<tr class=\"liste_titre\">";
-		print "<td>".$langs->trans("RSS")." ".($i+1)."</td>";
+		print "<td>".$langs->trans("RSS")." ".($i + 1)."</td>";
         print '<td class="right">';
         print "<input type=\"submit\" class=\"button\" name=\"modify\" value=\"".$langs->trans("Modify")."\">";
 		print " &nbsp; ";
@@ -270,13 +270,13 @@ if ($resql)
 
 		print '<tr class="oddeven">';
 		print "<td width=\"100px\">".$langs->trans("Title")."</td>";
-		print "<td><input type=\"text\" class=\"flat minwidth300\" name=\"external_rss_title_" . $idrss . "\" value=\"" . dol_escape_htmltag($conf->global->$keyrsstitle) . "\"></td>";
+		print "<td><input type=\"text\" class=\"flat minwidth300\" name=\"external_rss_title_".$idrss."\" value=\"".dol_escape_htmltag($conf->global->$keyrsstitle)."\"></td>";
 		print "</tr>";
 
 
 		print '<tr class="oddeven">';
 		print "<td>".$langs->trans("URL")."</td>";
-		print "<td><input type=\"text\" class=\"flat minwidth300\" name=\"external_rss_urlrss_" . $idrss . "\" value=\"" . dol_escape_htmltag($conf->global->$keyrssurl) . "\"></td>";
+		print "<td><input type=\"text\" class=\"flat minwidth300\" name=\"external_rss_urlrss_".$idrss."\" value=\"".dol_escape_htmltag($conf->global->$keyrssurl)."\"></td>";
 		print "</tr>";
 
 
@@ -303,9 +303,9 @@ if ($resql)
 			print '<tr class="oddeven">';
 			print "<td>".$langs->trans("Logo")."</td>";
 			print '<td>';
-			$imageurl=$rssparser->getImageUrl();
-			$linkrss=$rssparser->getLink();
-			if (! preg_match('/^http/', $imageurl)) $imageurl=$linkrss.$imageurl;
+			$imageurl = $rssparser->getImageUrl();
+			$linkrss = $rssparser->getLink();
+			if (!preg_match('/^http/', $imageurl)) $imageurl = $linkrss.$imageurl;
 			if ($imageurl) print '<img height="32" src="'.$imageurl.'">';
 			else print $langs->trans("None");
 			print '</td>';

+ 13 - 13
htdocs/admin/facture_situation.php

@@ -36,13 +36,13 @@ require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
 // Load translation files required by the page
 $langs->loadLangs(array('admin', 'errors', 'other', 'bills'));
 
-if (! $user->admin) accessforbidden();
+if (!$user->admin) accessforbidden();
 
 $action = GETPOST('action', 'alpha');
 $value = GETPOST('value', 'alpha');
 $label = GETPOST('label', 'alpha');
 $scandir = GETPOST('scan_dir', 'alpha');
-$type='invoice';
+$type = 'invoice';
 
 
 /*
@@ -57,17 +57,17 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
  * View
  */
 
-$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']);
+$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
 
 llxHeader(
     "", $langs->trans("BillsSetup"),
     'EN:Invoice_Configuration|FR:Configuration_module_facture|ES:ConfiguracionFactura'
 );
 
-$form=new Form($db);
+$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("BillsSetup"), $linkback, 'title_setup');
 
 $head = invoice_admin_prepare_head();
@@ -107,7 +107,7 @@ $metas = array(
 _printInputFormPart('INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_PERCENT', $langs->trans('RetainedwarrantyDefaultPercent'), '', $metas);
 
 // Conditions paiements
-$inputCount = empty($inputCount)?1:($inputCount+1);
+$inputCount = empty($inputCount) ? 1 : ($inputCount + 1);
 print '<tr class="oddeven">';
 print '<td>'.$langs->trans('PaymentConditionsShortRetainedWarranty').'</td>';
 print '<td class="center" width="20">&nbsp;</td>';
@@ -159,7 +159,7 @@ function _printOnOff($confkey, $title = false, $desc = '')
     global $langs;
 
     print '<tr class="oddeven">';
-    print '<td>'.($title?$title:$langs->trans($confkey));
+    print '<td>'.($title ? $title : $langs->trans($confkey));
     if (!empty($desc)) {
         print '<br><small>'.$langs->trans($desc).'</small>';
     }
@@ -187,14 +187,14 @@ function _printInputFormPart($confkey, $title = false, $desc = '', $metas = arra
 {
     global $langs, $conf, $db, $inputCount;
 
-    $inputCount = empty($inputCount)?1:($inputCount+1);
-    $form=new Form($db);
+    $inputCount = empty($inputCount) ? 1 : ($inputCount + 1);
+    $form = new Form($db);
 
     $defaultMetas = array(
         'name' => 'value'.$inputCount
     );
 
-    if ($type!='textarea') {
+    if ($type != 'textarea') {
         $defaultMetas['type']   = 'text';
         $defaultMetas['value']  = $conf->global->{$confkey};
     }
@@ -210,9 +210,9 @@ function _printInputFormPart($confkey, $title = false, $desc = '', $metas = arra
     print '<td>';
 
     if (!empty($help)) {
-        print $form->textwithtooltip(($title?$title:$langs->trans($confkey)), $langs->trans($help), 2, 1, img_help(1, ''));
+        print $form->textwithtooltip(($title ? $title : $langs->trans($confkey)), $langs->trans($help), 2, 1, img_help(1, ''));
     } else {
-        print $title?$title:$langs->trans($confkey);
+        print $title ? $title : $langs->trans($confkey);
     }
 
     if (!empty($desc)) {
@@ -225,7 +225,7 @@ function _printInputFormPart($confkey, $title = false, $desc = '', $metas = arra
     print '<input type="hidden" name="param'.$inputCount.'" value="'.$confkey.'">';
 
     print '<input type="hidden" name="action" value="setModuleOptions">';
-    if ($type=='textarea') {
+    if ($type == 'textarea') {
         print '<textarea '.$metascompil.'  >'.dol_htmlentities($conf->global->{$confkey}).'</textarea>';
     } else {
         print '<input '.$metascompil.'  />';

+ 35 - 35
htdocs/admin/fckeditor.php

@@ -39,7 +39,7 @@ $action = GETPOST('action', 'alpha');
 // dolibarr_readonly
 // dolibarr_mailings
 // Full (not sure this one is used)
-$mode=GETPOST('mode')?GETPOST('mode', 'alpha'):'dolibarr_notes';
+$mode = GETPOST('mode') ?GETPOST('mode', 'alpha') : 'dolibarr_notes';
 
 if (!$user->admin) accessforbidden();
 
@@ -56,12 +56,12 @@ $modules = array(
 // Conditions pour que l'option soit proposee
 $conditions = array(
 'SOCIETE' => 1,
-'PRODUCTDESC' => (! empty($conf->product->enabled) || ! empty($conf->service->enabled)),
-'DETAILS' => (! empty($conf->facture->enabled) || ! empty($conf->propal->enabled) || ! empty($conf->commande->enabled) || ! empty($conf->supplier_proposal->enabled) || ! empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || ! empty($conf->supplier_order->enabled) || ! empty($conf->supplier_invoice->enabled)),
+'PRODUCTDESC' => (!empty($conf->product->enabled) || !empty($conf->service->enabled)),
+'DETAILS' => (!empty($conf->facture->enabled) || !empty($conf->propal->enabled) || !empty($conf->commande->enabled) || !empty($conf->supplier_proposal->enabled) || !empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)),
 'USERSIGN' => 1,
-'MAILING' => ! empty($conf->mailing->enabled),
-'MAIL' => (! empty($conf->facture->enabled) || ! empty($conf->propal->enabled) || ! empty($conf->commande->enabled)),
-'TICKET' => ! empty($conf->ticket->enabled)
+'MAILING' => !empty($conf->mailing->enabled),
+'MAIL' => (!empty($conf->facture->enabled) || !empty($conf->propal->enabled) || !empty($conf->commande->enabled)),
+'TICKET' => !empty($conf->ticket->enabled)
 );
 // Picto
 $picto = array(
@@ -80,13 +80,13 @@ $picto = array(
  *  Actions
  */
 
-foreach($modules as $const => $desc)
+foreach ($modules as $const => $desc)
 {
     if ($action == 'activate_'.strtolower($const))
     {
         dolibarr_set_const($db, "FCKEDITOR_ENABLE_".$const, "1", 'chaine', 0, '', $conf->entity);
         // Si fckeditor est active dans la description produit/service, on l'active dans les formulaires
-        if ($const == 'PRODUCTDESC' && ! empty($conf->global->PRODUIT_DESC_IN_FORM))
+        if ($const == 'PRODUCTDESC' && !empty($conf->global->PRODUIT_DESC_IN_FORM))
         {
             dolibarr_set_const($db, "FCKEDITOR_ENABLE_DETAILS", "1", 'chaine', 0, '', $conf->entity);
         }
@@ -106,24 +106,24 @@ if (GETPOST('save', 'alpha'))
 	$error = 0;
 
 	$fckeditor_skin = GETPOST('fckeditor_skin', 'alpha');
-	if (! empty($fckeditor_skin)) {
-		if (! dolibarr_set_const($db, 'FCKEDITOR_SKIN', $fckeditor_skin, 'chaine', 0, '', $conf->entity)) {
-			$error ++;
+	if (!empty($fckeditor_skin)) {
+		if (!dolibarr_set_const($db, 'FCKEDITOR_SKIN', $fckeditor_skin, 'chaine', 0, '', $conf->entity)) {
+			$error++;
 		}
 	} else {
-		$error ++;
+		$error++;
 	}
 
 	$fckeditor_test = GETPOST('formtestfield');
-    if (! empty($fckeditor_test)) {
-		if (! dolibarr_set_const($db, 'FCKEDITOR_TEST', $fckeditor_test, 'chaine', 0, '', $conf->entity)) {
-			$error ++;
+    if (!empty($fckeditor_test)) {
+		if (!dolibarr_set_const($db, 'FCKEDITOR_TEST', $fckeditor_test, 'chaine', 0, '', $conf->entity)) {
+			$error++;
 		}
 	} else {
-		$error ++;
+		$error++;
 	}
 
-	if (! $error)
+	if (!$error)
     {
         setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
     }
@@ -139,7 +139,7 @@ if (GETPOST('save', 'alpha'))
 
 llxHeader();
 
-$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("AdvancedEditor"), $linkback, 'title_setup');
 print '<br>';
 
@@ -156,17 +156,17 @@ else
     print "</tr>\n";
 
     // Modules
-    foreach($modules as $const => $desc)
+    foreach ($modules as $const => $desc)
     {
         // Si condition non remplie, on ne propose pas l'option
-        if (! $conditions[$const]) continue;
+        if (!$conditions[$const]) continue;
 
         print '<tr class="oddeven">';
         print '<td width="16">'.img_object("", $picto[$const]).'</td>';
         print '<td>'.$langs->trans($desc).'</td>';
         print '<td class="center" width="100">';
         $constante = 'FCKEDITOR_ENABLE_'.$const;
-        $value = (isset($conf->global->$constante)?$conf->global->$constante:0);
+        $value = (isset($conf->global->$constante) ? $conf->global->$constante : 0);
         if ($value == 0)
         {
             print '<a href="'.$_SERVER['PHP_SELF'].'?action=activate_'.strtolower($const).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
@@ -185,31 +185,31 @@ else
 	print '<br>'."\n";
 
 	print '<form name="formtest" method="POST" action="'.$_SERVER["PHP_SELF"].'">'."\n";
-    print '<input type="hidden" name="token" value="' . newToken() . '">';
+    print '<input type="hidden" name="token" value="'.newToken().'">';
 
 	// Skins
     show_skin(null, 1);
     print '<br>'."\n";
 
-    $listofmodes=array('dolibarr_mailings', 'dolibarr_notes', 'dolibarr_details', 'dolibarr_readonly', 'Full', 'Full_inline');
-    $linkstomode='';
-    foreach($listofmodes as $newmode)
+    $listofmodes = array('dolibarr_mailings', 'dolibarr_notes', 'dolibarr_details', 'dolibarr_readonly', 'Full', 'Full_inline');
+    $linkstomode = '';
+    foreach ($listofmodes as $newmode)
     {
-        if ($linkstomode) $linkstomode.=' - ';
-        $linkstomode.='<a href="'.$_SERVER["PHP_SELF"].'?mode='.$newmode.'">';
-        if ($mode == $newmode) $linkstomode.='<strong>';
-        $linkstomode.=$newmode;
-        if ($mode == $newmode) $linkstomode.='</strong>';
-        $linkstomode.='</a>';
+        if ($linkstomode) $linkstomode .= ' - ';
+        $linkstomode .= '<a href="'.$_SERVER["PHP_SELF"].'?mode='.$newmode.'">';
+        if ($mode == $newmode) $linkstomode .= '<strong>';
+        $linkstomode .= $newmode;
+        if ($mode == $newmode) $linkstomode .= '</strong>';
+        $linkstomode .= '</a>';
     }
-    $linkstomode.='';
+    $linkstomode .= '';
 	print load_fiche_titre($langs->trans("TestSubmitForm"), $linkstomode, '');
     print '<input type="hidden" name="mode" value="'.dol_escape_htmltag($mode).'">';
     if ($mode != 'Full_inline')
     {
-        $uselocalbrowser=true;
-        $readonly=($mode=='dolibarr_readonly'?1:0);
-        $editor=new DolEditor('formtestfield', isset($conf->global->FCKEDITOR_TEST)?$conf->global->FCKEDITOR_TEST:'Test', '', 200, $mode, 'In', true, $uselocalbrowser, 1, 120, 8, $readonly);
+        $uselocalbrowser = true;
+        $readonly = ($mode == 'dolibarr_readonly' ? 1 : 0);
+        $editor = new DolEditor('formtestfield', isset($conf->global->FCKEDITOR_TEST) ? $conf->global->FCKEDITOR_TEST : 'Test', '', 200, $mode, 'In', true, $uselocalbrowser, 1, 120, 8, $readonly);
         $editor->Create();
     }
     else

+ 25 - 25
htdocs/admin/geoipmaxmind.php

@@ -32,7 +32,7 @@ if (!$user->admin)
 accessforbidden();
 
 // Load translation files required by the page
-$langs->loadLangs(array("admin","errors"));
+$langs->loadLangs(array("admin", "errors"));
 
 $action = GETPOST('action', 'aZ09');
 
@@ -43,25 +43,25 @@ $action = GETPOST('action', 'aZ09');
 
 if ($action == 'set')
 {
-	$error=0;
+	$error = 0;
 
-	$gimcdf= GETPOST("GEOIPMAXMIND_COUNTRY_DATAFILE");
+	$gimcdf = GETPOST("GEOIPMAXMIND_COUNTRY_DATAFILE");
 
-	if (! $gimcdf && ! file_exists($gimcdf))
+	if (!$gimcdf && !file_exists($gimcdf))
 	{
 		setEventMessages($langs->trans("ErrorFileNotFound", $gimcdf), null, 'errors');
 		$error++;
 	}
 
-	if (! $error)
+	if (!$error)
 	{
 		$res1 = dolibarr_set_const($db, "GEOIP_VERSION", GETPOST('geoipversion', 'aZ09'), 'chaine', 0, '', $conf->entity);
-		if (! $res1 > 0) $error++;
+		if (!$res1 > 0) $error++;
 
 		$res2 = dolibarr_set_const($db, "GEOIPMAXMIND_COUNTRY_DATAFILE", $gimcdf, 'chaine', 0, '', $conf->entity);
-		if (! $res2 > 0) $error++;
+		if (!$res2 > 0) $error++;
 
-		if (! $error)
+		if (!$error)
 		{
 			setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
 		}
@@ -72,26 +72,26 @@ if ($action == 'set')
 	}
 }
 
-if (! isset($conf->global->GEOIP_VERSION)) $conf->global->GEOIP_VERSION = '2';
+if (!isset($conf->global->GEOIP_VERSION)) $conf->global->GEOIP_VERSION = '2';
 
 
 /*
  * View
  */
 
-$form=new Form($db);
+$form = new Form($db);
 
 llxHeader();
 
-$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("GeoIPMaxmindSetup"), $linkback, 'title_setup');
 print '<br>';
 
-$version='';
-$geoip='';
-if (! empty($conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE))
+$version = '';
+$geoip = '';
+if (!empty($conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE))
 {
-	$geoip=new DolGeoIP('country', $conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE);
+	$geoip = new DolGeoIP('country', $conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE);
 }
 
 // Mode
@@ -112,7 +112,7 @@ $arrayofvalues = array('php' => 'Native PHP functions', '1' => 'Embedded GeoIP v
 print $form->selectarray('geoipversion', $arrayofvalues, (isset($conf->global->GEOIP_VERSION) ? $conf->global->GEOIP_VERSION : '2'));
 if ($conf->global->GEOIP_VERSION == 'php')
 {
-	if ($geoip) $version=$geoip->getVersion();
+	if ($geoip) $version = $geoip->getVersion();
 	if ($version)
 	{
 		print '<br>'.$langs->trans("Version").': '.$version;
@@ -139,12 +139,12 @@ print '<br>';
 
 print $langs->trans("NoteOnPathLocation").'<br>';
 
-$url1='http://www.maxmind.com/en/city?rId=awstats';
+$url1 = 'http://www.maxmind.com/en/city?rId=awstats';
 print $langs->trans("YouCanDownloadFreeDatFileTo", '<a href="'.$url1.'" target="_blank">'.$url1.'</a>');
 
 print '<br>';
 
-$url2='http://www.maxmind.com/en/city?rId=awstats';
+$url2 = 'http://www.maxmind.com/en/city?rId=awstats';
 print $langs->trans("YouCanDownloadAdvancedDatFileTo", '<a href="'.$url2.'" target="_blank">'.$url2.'</a>');
 
 if ($geoip)
@@ -152,15 +152,15 @@ if ($geoip)
 	print '<br><br>';
 	print '<br>'.$langs->trans("TestGeoIPResult", $ip).':';
 
-	$ip='24.24.24.24';
+	$ip = '24.24.24.24';
 	print '<br>'.$ip.' -> ';
-	$result=dol_print_ip($ip, 1);
+	$result = dol_print_ip($ip, 1);
 	if ($result) print $result;
 	else print $langs->trans("Error");
 
-	$ip='2a01:e0a:7e:4a60:429a:23ff:f7b8:dc8a';		// should be France
+	$ip = '2a01:e0a:7e:4a60:429a:23ff:f7b8:dc8a'; // should be France
 	print '<br>'.$ip.' -> ';
-	$result=dol_print_ip($ip, 1);
+	$result = dol_print_ip($ip, 1);
 	if ($result) print $result;
 	else print $langs->trans("Error");
 
@@ -175,18 +175,18 @@ if ($geoip)
 	//var_dump($_SERVER);
 	$ip = getUserRemoteIP();
 	//$ip='91.161.249.43';
-	$isip=is_ip($ip);
+	$isip = is_ip($ip);
 	if ($isip == 1)
 	{
 		print '<br>'.$ip.' -> ';
-		$result=dol_print_ip($ip, 1);
+		$result = dol_print_ip($ip, 1);
 		if ($result) print $result;
 		else print $langs->trans("Error");
 	}
 	else
 	{
 		print '<br>'.$ip.' -> ';
-		$result=dol_print_ip($ip, 1);
+		$result = dol_print_ip($ip, 1);
 		if ($result) print $result;
 		else print $langs->trans("NotAPublicIp");
 	}

+ 8 - 8
htdocs/admin/holiday_extrafields.php

@@ -40,13 +40,13 @@ $extrafields = new ExtraFields($db);
 $form = new Form($db);
 
 // List of supported format
-$tmptype2label=ExtraFields::$type2label;
-$type2label=array('');
-foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
+$tmptype2label = ExtraFields::$type2label;
+$type2label = array('');
+foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val);
 
-$action=GETPOST('action', 'alpha');
-$attrname=GETPOST('attrname', 'alpha');
-$elementtype='holiday'; //Must be the $table_element of the class that manage extrafield
+$action = GETPOST('action', 'alpha');
+$attrname = GETPOST('attrname', 'alpha');
+$elementtype = 'holiday'; //Must be the $table_element of the class that manage extrafield
 
 if (!$user->admin) accessforbidden();
 
@@ -65,7 +65,7 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
 
 llxHeader('', $langs->trans("HolidaySetup"));
 
-$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("HolidaySetup"), $linkback, 'title_setup');
 
 $head = holiday_admin_prepare_head();
@@ -105,7 +105,7 @@ if ($action == 'create')
 /* Edition of an optional field                                               */
 /*                                                                            */
 /* ************************************************************************** */
-if ($action == 'edit' && ! empty($attrname))
+if ($action == 'edit' && !empty($attrname))
 {
     print "<br>";
     print load_fiche_titre($langs->trans("FieldEdition", $attrname));

+ 8 - 8
htdocs/admin/index.php

@@ -39,23 +39,23 @@ $hookmanager->initHooks(array('homesetup'));
 
 $form = new Form($db);
 
-$wikihelp='EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones';
+$wikihelp = 'EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones';
 llxHeader('', $langs->trans("Setup"), $wikihelp);
 
 
 print load_fiche_titre($langs->trans("SetupArea"), '', 'tools');
 
-if (! empty($conf->global->MAIN_MOTD_SETUPPAGE))
+if (!empty($conf->global->MAIN_MOTD_SETUPPAGE))
 {
-    $conf->global->MAIN_MOTD_SETUPPAGE=preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>/i', '<br>', $conf->global->MAIN_MOTD_SETUPPAGE);
-    if (! empty($conf->global->MAIN_MOTD_SETUPPAGE))
+    $conf->global->MAIN_MOTD_SETUPPAGE = preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>/i', '<br>', $conf->global->MAIN_MOTD_SETUPPAGE);
+    if (!empty($conf->global->MAIN_MOTD_SETUPPAGE))
     {
-    	$i=0;
+    	$i = 0;
     	while (preg_match('/__\(([a-zA-Z|@]+)\)__/i', $conf->global->MAIN_MOTD_SETUPPAGE, $reg) && $i < 100)
     	{
-    		$tmp=explode('|', $reg[1]);
-    		if (! empty($tmp[1])) $langs->load($tmp[1]);
-    		$conf->global->MAIN_MOTD_SETUPPAGE=preg_replace('/__\('.preg_quote($reg[1]).'\)__/i', $langs->trans($tmp[0]), $conf->global->MAIN_MOTD_SETUPPAGE);
+    		$tmp = explode('|', $reg[1]);
+    		if (!empty($tmp[1])) $langs->load($tmp[1]);
+    		$conf->global->MAIN_MOTD_SETUPPAGE = preg_replace('/__\('.preg_quote($reg[1]).'\)__/i', $langs->trans($tmp[0]), $conf->global->MAIN_MOTD_SETUPPAGE);
     		$i++;
     	}
 

+ 59 - 59
htdocs/admin/ldap.php

@@ -40,38 +40,38 @@ if (!$user->admin)
 $action = GETPOST('action', 'aZ09');
 
 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
-$hookmanager->initHooks(array('adminldap','globaladmin'));
+$hookmanager->initHooks(array('adminldap', 'globaladmin'));
 
 /*
  * 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 (empty($reshook))
 {
 	if ($action == 'setvalue' && $user->admin)
 	{
-		$error=0;
+		$error = 0;
 
 		$db->begin();
-		if (! dolibarr_set_const($db, 'LDAP_SERVER_TYPE', GETPOST("type"), 'chaine', 0, '', $conf->entity)) $error++;
-		if (! dolibarr_set_const($db, 'LDAP_SERVER_PROTOCOLVERSION', GETPOST("LDAP_SERVER_PROTOCOLVERSION"), 'chaine', 0, '', $conf->entity)) $error++;
-		if (! dolibarr_set_const($db, 'LDAP_SERVER_HOST', GETPOST("host"), 'chaine', 0, '', $conf->entity)) $error++;
-		if (! dolibarr_set_const($db, 'LDAP_SERVER_HOST_SLAVE', GETPOST("slave"), 'chaine', 0, '', $conf->entity)) $error++;
-		if (! dolibarr_set_const($db, 'LDAP_SERVER_PORT', GETPOST("port"), 'chaine', 0, '', $conf->entity)) $error++;
-		if (! dolibarr_set_const($db, 'LDAP_SERVER_DN', GETPOST("dn"), 'chaine', 0, '', $conf->entity)) $error++;
-		if (! dolibarr_set_const($db, 'LDAP_ADMIN_DN', GETPOST("admin"), 'chaine', 0, '', $conf->entity)) $error++;
-		if (! dolibarr_set_const($db, 'LDAP_ADMIN_PASS', GETPOST("pass"), 'chaine', 0, '', $conf->entity)) $error++;
-		if (! dolibarr_set_const($db, 'LDAP_SERVER_USE_TLS', GETPOST("usetls"), 'chaine', 0, '', $conf->entity)) $error++;
-		if (! dolibarr_set_const($db, 'LDAP_SYNCHRO_ACTIVE', GETPOST("activesynchro"), 'chaine', 0, '', $conf->entity)) $error++;
-		if (! dolibarr_set_const($db, 'LDAP_CONTACT_ACTIVE', GETPOST("activecontact"), 'chaine', 0, '', $conf->entity)) $error++;
-		if (! dolibarr_set_const($db, 'LDAP_MEMBER_ACTIVE', GETPOST("activemembers"), 'chaine', 0, '', $conf->entity)) $error++;
-		if (! dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_ACTIVE', GETPOST("activememberstypes"), 'chaine', 0, '', $conf->entity)) $error++;
-
-		if (! $error)
+		if (!dolibarr_set_const($db, 'LDAP_SERVER_TYPE', GETPOST("type"), 'chaine', 0, '', $conf->entity)) $error++;
+		if (!dolibarr_set_const($db, 'LDAP_SERVER_PROTOCOLVERSION', GETPOST("LDAP_SERVER_PROTOCOLVERSION"), 'chaine', 0, '', $conf->entity)) $error++;
+		if (!dolibarr_set_const($db, 'LDAP_SERVER_HOST', GETPOST("host"), 'chaine', 0, '', $conf->entity)) $error++;
+		if (!dolibarr_set_const($db, 'LDAP_SERVER_HOST_SLAVE', GETPOST("slave"), 'chaine', 0, '', $conf->entity)) $error++;
+		if (!dolibarr_set_const($db, 'LDAP_SERVER_PORT', GETPOST("port"), 'chaine', 0, '', $conf->entity)) $error++;
+		if (!dolibarr_set_const($db, 'LDAP_SERVER_DN', GETPOST("dn"), 'chaine', 0, '', $conf->entity)) $error++;
+		if (!dolibarr_set_const($db, 'LDAP_ADMIN_DN', GETPOST("admin"), 'chaine', 0, '', $conf->entity)) $error++;
+		if (!dolibarr_set_const($db, 'LDAP_ADMIN_PASS', GETPOST("pass"), 'chaine', 0, '', $conf->entity)) $error++;
+		if (!dolibarr_set_const($db, 'LDAP_SERVER_USE_TLS', GETPOST("usetls"), 'chaine', 0, '', $conf->entity)) $error++;
+		if (!dolibarr_set_const($db, 'LDAP_SYNCHRO_ACTIVE', GETPOST("activesynchro"), 'chaine', 0, '', $conf->entity)) $error++;
+		if (!dolibarr_set_const($db, 'LDAP_CONTACT_ACTIVE', GETPOST("activecontact"), 'chaine', 0, '', $conf->entity)) $error++;
+		if (!dolibarr_set_const($db, 'LDAP_MEMBER_ACTIVE', GETPOST("activemembers"), 'chaine', 0, '', $conf->entity)) $error++;
+		if (!dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_ACTIVE', GETPOST("activememberstypes"), 'chaine', 0, '', $conf->entity)) $error++;
+
+		if (!$error)
 		{
 			$db->commit();
 			setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
@@ -90,20 +90,20 @@ if (empty($reshook))
 
 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');
 }
 
 
-$form=new Form($db);
+$form = new Form($db);
 
 
 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?action=setvalue">';
@@ -121,56 +121,56 @@ print "</tr>\n";
 // Synchro utilisateurs/groupes active
 
 print '<tr class="oddeven"><td>'.$langs->trans("LDAPDnSynchroActive").'</td><td>';
-$arraylist=array();
-$arraylist['0']=$langs->trans("No");
-$arraylist['ldap2dolibarr']=$langs->trans("LDAPToDolibarr");
-$arraylist['dolibarr2ldap']=$langs->trans("DolibarrToLDAP");
+$arraylist = array();
+$arraylist['0'] = $langs->trans("No");
+$arraylist['ldap2dolibarr'] = $langs->trans("LDAPToDolibarr");
+$arraylist['dolibarr2ldap'] = $langs->trans("DolibarrToLDAP");
 print $form->selectarray('activesynchro', $arraylist, $conf->global->LDAP_SYNCHRO_ACTIVE);
 print '</td><td>'.$langs->trans("LDAPDnSynchroActiveExample");
-if ($conf->global->LDAP_SYNCHRO_ACTIVE && ! $conf->global->LDAP_USER_DN)
+if ($conf->global->LDAP_SYNCHRO_ACTIVE && !$conf->global->LDAP_USER_DN)
 {
 	print '<br><font class="error">'.$langs->trans("LDAPSetupNotComplete").'</font>';
 }
 print '</td></tr>';
 
 // Synchro contact active
-if (! empty($conf->societe->enabled))
+if (!empty($conf->societe->enabled))
 {
 	print '<tr class="oddeven"><td>'.$langs->trans("LDAPDnContactActive").'</td><td>';
-	$arraylist=array();
-	$arraylist['0']=$langs->trans("No");
-	$arraylist['1']=$langs->trans("DolibarrToLDAP");
+	$arraylist = array();
+	$arraylist['0'] = $langs->trans("No");
+	$arraylist['1'] = $langs->trans("DolibarrToLDAP");
 	print $form->selectarray('activecontact', $arraylist, $conf->global->LDAP_CONTACT_ACTIVE);
 	print '</td><td>'.$langs->trans("LDAPDnContactActiveExample").'</td></tr>';
 }
 
 // Synchro member active
-if (! empty($conf->adherent->enabled))
+if (!empty($conf->adherent->enabled))
 {
 	print '<tr class="oddeven"><td>'.$langs->trans("LDAPDnMemberActive").'</td><td>';
-	$arraylist=array();
-	$arraylist['0']=$langs->trans("No");
-	$arraylist['1']=$langs->trans("DolibarrToLDAP");
-	$arraylist['ldap2dolibarr']=$langs->trans("LDAPToDolibarr").' ('.$langs->trans("SupportedForLDAPImportScriptOnly").')';
+	$arraylist = array();
+	$arraylist['0'] = $langs->trans("No");
+	$arraylist['1'] = $langs->trans("DolibarrToLDAP");
+	$arraylist['ldap2dolibarr'] = $langs->trans("LDAPToDolibarr").' ('.$langs->trans("SupportedForLDAPImportScriptOnly").')';
 	print $form->selectarray('activemembers', $arraylist, $conf->global->LDAP_MEMBER_ACTIVE);
 	print '</td><td>'.$langs->trans("LDAPDnMemberActiveExample").'</td></tr>';
 }
 
 // Synchro member type active
-if (! empty($conf->adherent->enabled))
+if (!empty($conf->adherent->enabled))
 {
 	print '<tr class="oddeven"><td>'.$langs->trans("LDAPDnMemberTypeActive").'</td><td>';
-	$arraylist=array();
-	$arraylist['0']=$langs->trans("No");
-	$arraylist['1']=$langs->trans("DolibarrToLDAP");
-	$arraylist['ldap2dolibarr']=$langs->trans("LDAPToDolibarr").' ('.$langs->trans("SupportedForLDAPImportScriptOnly").')';
+	$arraylist = array();
+	$arraylist['0'] = $langs->trans("No");
+	$arraylist['1'] = $langs->trans("DolibarrToLDAP");
+	$arraylist['ldap2dolibarr'] = $langs->trans("LDAPToDolibarr").' ('.$langs->trans("SupportedForLDAPImportScriptOnly").')';
 	print $form->selectarray('activememberstypes', $arraylist, $conf->global->LDAP_MEMBER_TYPE_ACTIVE);
 	print '</td><td>'.$langs->trans("LDAPDnMemberTypeActiveExample").'</td></tr>';
 }
 
 // Fields from hook
-$parameters=array();
-$reshook=$hookmanager->executeHooks('addAdminLdapOptions', $parameters);    // Note that $action and $object may have been modified by hook
+$parameters = array();
+$reshook = $hookmanager->executeHooks('addAdminLdapOptions', $parameters); // Note that $action and $object may have been modified by hook
 print $hookmanager->resPrint;
 
 print '<tr class="liste_titre">';
@@ -181,18 +181,18 @@ print "</tr>\n";
 
 // Type
 print '<tr class="oddeven"><td>'.$langs->trans("Type").'</td><td>';
-$arraylist=array();
-$arraylist['activedirectory']='Active Directory';
-$arraylist['openldap']='OpenLdap';
-$arraylist['egroupware']='Egroupware';
+$arraylist = array();
+$arraylist['activedirectory'] = 'Active Directory';
+$arraylist['openldap'] = 'OpenLdap';
+$arraylist['egroupware'] = 'Egroupware';
 print $form->selectarray('type', $arraylist, $conf->global->LDAP_SERVER_TYPE);
 print '</td><td>&nbsp;</td></tr>';
 
 // Version
 print '<tr class="oddeven"><td>'.$langs->trans("Version").'</td><td>';
-$arraylist=array();
-$arraylist['3']='Version 3';
-$arraylist['2']='Version 2';
+$arraylist = array();
+$arraylist['3'] = 'Version 3';
+$arraylist['2'] = 'Version 2';
 print $form->selectarray('LDAP_SERVER_PROTOCOLVERSION', $arraylist, $conf->global->LDAP_SERVER_PROTOCOLVERSION);
 print '</td><td>'.$langs->trans("LDAPServerProtocolVersion").'</td></tr>';
 
@@ -210,7 +210,7 @@ print '</td><td>'.$langs->trans("LDAPServerExample").'</td></tr>';
 
 // Port
 print '<tr class="oddeven"><td>'.$langs->trans("LDAPServerPort").'</td><td>';
-if (! empty($conf->global->LDAP_SERVER_PORT))
+if (!empty($conf->global->LDAP_SERVER_PORT))
 {
 	print '<input size="25" type="text" name="port" value="'.$conf->global->LDAP_SERVER_PORT.'">';
 }
@@ -227,9 +227,9 @@ print '</td><td>'.$langs->trans("LDAPServerDnExample").'</td></tr>';
 
 // Utiliser TLS
 print '<tr class="oddeven"><td>'.$langs->trans("LDAPServerUseTLS").'</td><td>';
-$arraylist=array();
-$arraylist['0']=$langs->trans("No");
-$arraylist['1']=$langs->trans("Yes");
+$arraylist = array();
+$arraylist['0'] = $langs->trans("No");
+$arraylist['1'] = $langs->trans("Yes");
 print $form->selectarray('usetls', $arraylist, $conf->global->LDAP_SERVER_USE_TLS);
 print '</td><td>'.$langs->trans("LDAPServerUseTLSExample").'</td></tr>';
 
@@ -244,9 +244,9 @@ print '</td><td>'.$langs->trans("LDAPAdminDnExample").'</td></tr>';
 
 // Pass
 print '<tr class="oddeven"><td>'.$langs->trans("LDAPPassword").'</td><td>';
-if (! empty($conf->global->LDAP_ADMIN_PASS))
+if (!empty($conf->global->LDAP_ADMIN_PASS))
 {
-	print '<input size="25" type="password" name="pass" value="'.$conf->global->LDAP_ADMIN_PASS.'">';// je le met en visible pour test
+	print '<input size="25" type="password" name="pass" value="'.$conf->global->LDAP_ADMIN_PASS.'">'; // je le met en visible pour test
 }
 else
 {
@@ -270,14 +270,14 @@ print '<br>';
  */
 if (function_exists("ldap_connect"))
 {
-	if (! empty($conf->global->LDAP_SERVER_HOST))
+	if (!empty($conf->global->LDAP_SERVER_HOST))
 	{
 		print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=test">'.$langs->trans("LDAPTestConnect").'</a><br><br>';
 	}
 
 	if ($_GET["action"] == 'test')
 	{
-		$ldap = new Ldap();	// Les parametres sont passes et recuperes via $conf
+		$ldap = new Ldap(); // Les parametres sont passes et recuperes via $conf
 
 		$result = $ldap->connect_bind();
 		if ($result > 0)
@@ -287,7 +287,7 @@ if (function_exists("ldap_connect"))
 			print '<font class="ok">'.$langs->trans("LDAPTCPConnectOK", $conf->global->LDAP_SERVER_HOST, $conf->global->LDAP_SERVER_PORT).'</font>';
 			print '<br>';
 
-			if ($conf->global->LDAP_ADMIN_DN && ! empty($conf->global->LDAP_ADMIN_PASS))
+			if ($conf->global->LDAP_ADMIN_DN && !empty($conf->global->LDAP_ADMIN_PASS))
 			{
 				if ($result == 2)
 				{

+ 54 - 54
htdocs/admin/ldap_contacts.php

@@ -33,7 +33,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/ldap.lib.php';
 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
 
 // Load translation files required by the page
-$langs->loadLangs(array("admin","errors"));
+$langs->loadLangs(array("admin", "errors"));
 
 if (!$user->admin)
   accessforbidden();
@@ -46,35 +46,35 @@ $action = GETPOST('action', 'aZ09');
 
 if ($action == 'setvalue' && $user->admin)
 {
-	$error=0;
+	$error = 0;
 
 	$db->begin();
 
-	if (! dolibarr_set_const($db, 'LDAP_CONTACT_DN', GETPOST("contactdn"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_CONTACT_OBJECT_CLASS', GETPOST("objectclass"), 'chaine', 0, '', $conf->entity)) $error++;
-
-	if (! dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_FULLNAME', GETPOST("fieldfullname"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_NAME', GETPOST("fieldname"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_FIRSTNAME', GETPOST("fieldfirstname"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_COMPANY', GETPOST("fieldcompany"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_MAIL', GETPOST("fieldmail"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_PHONE', GETPOST("fieldphone"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_HOMEPHONE', GETPOST("fieldhomephone"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_MOBILE', GETPOST("fieldmobile"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_SKYPE', GETPOST("fieldskype"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_FAX', GETPOST("fieldfax"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_ADDRESS', GETPOST("fieldaddress"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_ZIP', GETPOST("fieldzip"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_TOWN', GETPOST("fieldtown"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_COUNTRY', GETPOST("fieldcountry"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_CONTACT_DN', GETPOST("contactdn"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_CONTACT_OBJECT_CLASS', GETPOST("objectclass"), 'chaine', 0, '', $conf->entity)) $error++;
+
+	if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_FULLNAME', GETPOST("fieldfullname"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_NAME', GETPOST("fieldname"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_FIRSTNAME', GETPOST("fieldfirstname"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_COMPANY', GETPOST("fieldcompany"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_MAIL', GETPOST("fieldmail"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_PHONE', GETPOST("fieldphone"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_HOMEPHONE', GETPOST("fieldhomephone"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_MOBILE', GETPOST("fieldmobile"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_SKYPE', GETPOST("fieldskype"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_FAX', GETPOST("fieldfax"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_ADDRESS', GETPOST("fieldaddress"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_ZIP', GETPOST("fieldzip"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_TOWN', GETPOST("fieldtown"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_COUNTRY', GETPOST("fieldcountry"), '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_CONTACTS', $valkey, 'chaine', 0, '', $conf->entity)) $error++;
+	$valkey = '';
+	$key = GETPOST("key");
+	if ($key) $valkey = $conf->global->$key;
+	if (!dolibarr_set_const($db, 'LDAP_KEY_CONTACTS', $valkey, 'chaine', 0, '', $conf->entity)) $error++;
 
-	if (! $error)
+	if (!$error)
 	{
 		$db->commit();
 		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
@@ -92,17 +92,17 @@ if ($action == 'setvalue' && $user->admin)
  * View
  */
 
-$form=new Form($db);
+$form = new Form($db);
 
 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');
 }
@@ -150,98 +150,98 @@ print "</tr>\n";
 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldFullname").'</td><td>';
 print '<input size="25" type="text" name="fieldfullname" value="'.$conf->global->LDAP_CONTACT_FIELD_FULLNAME.'">';
 print '</td><td>'.$langs->trans("LDAPFieldFullnameExample").'</td>';
-print '<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_FULLNAME"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_CONTACT_FIELD_FULLNAME?' checked':'')."></td>";
+print '<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_FULLNAME"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_FULLNAME ? ' checked' : '')."></td>";
 print '</tr>';
 
 // Name
 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldName").'</td><td>';
 print '<input size="25" type="text" name="fieldname" value="'.$conf->global->LDAP_CONTACT_FIELD_NAME.'">';
 print '</td><td>'.$langs->trans("LDAPFieldNameExample").'</td>';
-print '<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_NAME"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_CONTACT_FIELD_NAME?' checked':'')."></td>";
+print '<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_NAME"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_NAME ? ' checked' : '')."></td>";
 print '</tr>';
 
 // Firstname
 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldFirstName").'</td><td>';
 print '<input size="25" type="text" name="fieldfirstname" value="'.$conf->global->LDAP_CONTACT_FIELD_FIRSTNAME.'">';
 print '</td><td>'.$langs->trans("LDAPFieldFirstNameExample").'</td>';
-print '<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_FIRSTNAME"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_CONTACT_FIELD_FIRSTNAME?' checked':'')."></td>";
+print '<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_FIRSTNAME"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_FIRSTNAME ? ' checked' : '')."></td>";
 print '</tr>';
 
 // Company
 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldCompany").'</td><td>';
 print '<input size="25" type="text" name="fieldcompany" value="'.$conf->global->LDAP_CONTACT_FIELD_COMPANY.'">';
 print '</td><td>'.$langs->trans("LDAPFieldCompanyExample").'</td>';
-print '<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_COMPANY"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_CONTACT_FIELD_COMPANY?' checked':'')."></td>";
+print '<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_COMPANY"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_COMPANY ? ' checked' : '')."></td>";
 print '</tr>';
 
 // Mail
 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldMail").'</td><td>';
 print '<input size="25" type="text" name="fieldmail" value="'.$conf->global->LDAP_CONTACT_FIELD_MAIL.'">';
 print '</td><td>'.$langs->trans("LDAPFieldMailExample").'</td>';
-print '<td class="right"><input type="radio" name="key" value=">LDAP_CONTACT_FIELD_MAIL"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_CONTACT_FIELD_MAIL?' checked':'')."></td>";
+print '<td class="right"><input type="radio" name="key" value=">LDAP_CONTACT_FIELD_MAIL"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_MAIL ? ' checked' : '')."></td>";
 print '</tr>';
 
 // Phone pro
 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldPhone").'</td><td>';
 print '<input size="25" type="text" name="fieldphone" value="'.$conf->global->LDAP_CONTACT_FIELD_PHONE.'">';
 print '</td><td>'.$langs->trans("LDAPFieldPhoneExample").'</td>';
-print '<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_PHONE"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_CONTACT_FIELD_PHONE?' checked':'')."></td>";
+print '<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_PHONE"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_PHONE ? ' checked' : '')."></td>";
 print '</tr>';
 
 // Phone home
 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldHomePhone").'</td><td>';
 print '<input size="25" type="text" name="fieldhomephone" value="'.$conf->global->LDAP_CONTACT_FIELD_HOMEPHONE.'">';
 print '</td><td>'.$langs->trans("LDAPFieldHomePhoneExample").'</td>';
-print '<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_HOMEPHONE"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_CONTACT_FIELD_HOMEPHONE?' checked':'')."></td>";
+print '<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_HOMEPHONE"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_HOMEPHONE ? ' checked' : '')."></td>";
 print '</tr>';
 
 // Mobile
 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldMobile").'</td><td>';
 print '<input size="25" type="text" name="fieldmobile" value="'.$conf->global->LDAP_CONTACT_FIELD_MOBILE.'">';
 print '</td><td>'.$langs->trans("LDAPFieldMobileExample").'</td>';
-print '<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_MOBILE"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_CONTACT_FIELD_MOBILE?' checked':'')."></td>";
+print '<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_MOBILE"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_MOBILE ? ' checked' : '')."></td>";
 print '</tr>';
 
 // Skype
 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldSkype").'</td><td>';
 print '<input size="25" type="text" name="fieldskype" value="'.$conf->global->LDAP_CONTACT_FIELD_SKYPE.'">';
 print '</td><td>'.$langs->trans("LDAPFieldSkypeExample").'</td>';
-print '<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_SKYPE"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_CONTACT_FIELD_SKYPE?' checked':'')."></td>";
+print '<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_SKYPE"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_SKYPE ? ' checked' : '')."></td>";
 print '</tr>';
 
 // Fax
 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldFax").'</td><td>';
 print '<input size="25" type="text" name="fieldfax" value="'.$conf->global->LDAP_CONTACT_FIELD_FAX.'">';
 print '</td><td>'.$langs->trans("LDAPFieldFaxExample").'</td>';
-print '<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_FAX"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_CONTACT_FIELD_FAX?' checked':'')."></td>";
+print '<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_FAX"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_FAX ? ' checked' : '')."></td>";
 print '</tr>';
 
 // Address
 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldAddress").'</td><td>';
 print '<input size="25" type="text" name="fieldaddress" value="'.$conf->global->LDAP_CONTACT_FIELD_ADDRESS.'">';
 print '</td><td>'.$langs->trans("LDAPFieldAddressExample").'</td>';
-print '<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_ADDRESS"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_CONTACT_FIELD_ADDRESS?' checked':'')."></td>";
+print '<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_ADDRESS"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_ADDRESS ? ' checked' : '')."></td>";
 print '</tr>';
 
 // ZIP
 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldZip").'</td><td>';
 print '<input size="25" type="text" name="fieldzip" value="'.$conf->global->LDAP_CONTACT_FIELD_ZIP.'">';
 print '</td><td>'.$langs->trans("LDAPFieldZipExample").'</td>';
-print '<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_ZIP"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_CONTACT_FIELD_ZIP?' checked':'')."></td>";
+print '<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_ZIP"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_ZIP ? ' checked' : '')."></td>";
 print '</tr>';
 
 // TOWN
 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldTown").'</td><td>';
 print '<input size="25" type="text" name="fieldtown" value="'.$conf->global->LDAP_CONTACT_FIELD_TOWN.'">';
 print '</td><td>'.$langs->trans("LDAPFieldTownExample").'</td>';
-print '<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_TOWN"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_CONTACT_FIELD_TOWN?' checked':'')."></td>";
+print '<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_TOWN"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_TOWN ? ' checked' : '')."></td>";
 print '</tr>';
 
 // COUNTRY
 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldCountry").'</td><td>';
 print '<input size="25" type="text" name="fieldcountry" value="'.$conf->global->LDAP_CONTACT_FIELD_COUNTRY.'">';
 print '</td><td>&nbsp;</td>';
-print '<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_COUNTRY"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_CONTACT_FIELD_COUNTRY?' checked':'')."></td>";
+print '<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_COUNTRY"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_COUNTRY ? ' checked' : '')."></td>";
 print '</tr>';
 
 print '</table>';
@@ -258,11 +258,11 @@ print '</form>';
 /*
  * Test de la connexion
  */
-$butlabel=$langs->trans("LDAPTestSynchroContact");
-$testlabel='test';
-$key=$conf->global->LDAP_KEY_CONTACTS;
-$dn=$conf->global->LDAP_CONTACT_DN;
-$objectclass=$conf->global->LDAP_CONTACT_OBJECT_CLASS;
+$butlabel = $langs->trans("LDAPTestSynchroContact");
+$testlabel = 'test';
+$key = $conf->global->LDAP_KEY_CONTACTS;
+$dn = $conf->global->LDAP_CONTACT_DN;
+$objectclass = $conf->global->LDAP_CONTACT_OBJECT_CLASS;
 
 show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass);
 
@@ -272,21 +272,21 @@ if (function_exists("ldap_connect"))
 	if ($_GET["action"] == 'test')
 	{
 		// Creation objet
-		$object=new Contact($db);
+		$object = new Contact($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);
 
-			$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)
 			{

+ 58 - 58
htdocs/admin/ldap_members.php

@@ -47,51 +47,51 @@ $action = GETPOST('action', 'aZ09');
 
 if ($action == 'setvalue' && $user->admin)
 {
-	$error=0;
+	$error = 0;
 
 	$db->begin();
 
-	if (! dolibarr_set_const($db, 'LDAP_MEMBER_DN', GETPOST("user"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_MEMBER_OBJECT_CLASS', GETPOST("objectclass"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_MEMBER_FILTER', GETPOST("filterconnection"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_MEMBER_DN', GETPOST("user"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_MEMBER_OBJECT_CLASS', GETPOST("objectclass"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_MEMBER_FILTER', GETPOST("filterconnection"), 'chaine', 0, '', $conf->entity)) $error++;
 	// Members
-	if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FULLNAME', GETPOST("fieldfullname"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_LOGIN', GETPOST("fieldlogin"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_LOGIN_SAMBA', GETPOST("fieldloginsamba"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PASSWORD', GETPOST("fieldpassword"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PASSWORD_CRYPTED', GETPOST("fieldpasswordcrypted"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_NAME', GETPOST("fieldname"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FIRSTNAME', GETPOST("fieldfirstname"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_MAIL', GETPOST("fieldmail"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PHONE', GETPOST("fieldphone"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PHONE_PERSO', GETPOST("fieldphoneperso"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_MOBILE', GETPOST("fieldmobile"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_SKYPE', GETPOST("fieldskype"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FAX', GETPOST("fieldfax"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_COMPANY', GETPOST("fieldcompany"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_ADDRESS', GETPOST("fieldaddress"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_ZIP', GETPOST("fieldzip"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_TOWN', GETPOST("fieldtown"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_COUNTRY', GETPOST("fieldcountry"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_DESCRIPTION', GETPOST("fielddescription"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_NOTE_PUBLIC', GETPOST("fieldnotepublic"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_BIRTHDATE', GETPOST("fieldbirthdate"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_STATUS', GETPOST("fieldstatus"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION', GETPOST("fieldendlastsubscription"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FULLNAME', GETPOST("fieldfullname"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_LOGIN', GETPOST("fieldlogin"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_LOGIN_SAMBA', GETPOST("fieldloginsamba"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PASSWORD', GETPOST("fieldpassword"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PASSWORD_CRYPTED', GETPOST("fieldpasswordcrypted"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_NAME', GETPOST("fieldname"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FIRSTNAME', GETPOST("fieldfirstname"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_MAIL', GETPOST("fieldmail"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PHONE', GETPOST("fieldphone"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PHONE_PERSO', GETPOST("fieldphoneperso"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_MOBILE', GETPOST("fieldmobile"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_SKYPE', GETPOST("fieldskype"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FAX', GETPOST("fieldfax"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_COMPANY', GETPOST("fieldcompany"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_ADDRESS', GETPOST("fieldaddress"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_ZIP', GETPOST("fieldzip"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_TOWN', GETPOST("fieldtown"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_COUNTRY', GETPOST("fieldcountry"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_DESCRIPTION', GETPOST("fielddescription"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_NOTE_PUBLIC', GETPOST("fieldnotepublic"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_BIRTHDATE', GETPOST("fieldbirthdate"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_STATUS', GETPOST("fieldstatus"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION', GETPOST("fieldendlastsubscription"), 'chaine', 0, '', $conf->entity)) $error++;
 
 	// Subscriptions
-	if (! dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE', GETPOST("fieldfirstsubscriptiondate"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT', GETPOST("fieldfirstsubscriptionamount"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE', GETPOST("fieldlastsubscriptiondate"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT', GETPOST("fieldlastsubscriptionamount"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE', GETPOST("fieldfirstsubscriptiondate"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT', GETPOST("fieldfirstsubscriptionamount"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE', GETPOST("fieldlastsubscriptiondate"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT', GETPOST("fieldlastsubscriptionamount"), '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', $valkey, 'chaine', 0, '', $conf->entity)) $error++;
+	$valkey = '';
+	$key = GETPOST("key");
+	if ($key) $valkey = $conf->global->$key;
+	if (!dolibarr_set_const($db, 'LDAP_KEY_MEMBERS', $valkey, 'chaine', 0, '', $conf->entity)) $error++;
 
-	if (! $error)
+	if (!$error)
 	{
 		$db->commit();
 		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
@@ -109,17 +109,17 @@ if ($action == 'setvalue' && $user->admin)
  * View
  */
 
-$form=new Form($db);
+$form = new Form($db);
 
 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');
 }
@@ -176,14 +176,14 @@ print "</tr>\n";
 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldFullname").'</td><td>';
 print '<input size="25" type="text" name="fieldfullname" value="'.$conf->global->LDAP_MEMBER_FIELD_FULLNAME.'">';
 print '</td><td>'.$langs->trans("LDAPFieldFullnameExample").'</td>';
-print '<td class="right"><input type="radio" name="key" value="LDAP_MEMBER_FIELD_FULLNAME"'.(($conf->global->LDAP_KEY_MEMBERS && $conf->global->LDAP_KEY_MEMBERS==$conf->global->LDAP_MEMBER_FIELD_FULLNAME)?' checked':'')."></td>";
+print '<td class="right"><input type="radio" name="key" value="LDAP_MEMBER_FIELD_FULLNAME"'.(($conf->global->LDAP_KEY_MEMBERS && $conf->global->LDAP_KEY_MEMBERS == $conf->global->LDAP_MEMBER_FIELD_FULLNAME) ? ' checked' : '')."></td>";
 print '</tr>';
 
 // Name
 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldName").'</td><td>';
 print '<input size="25" type="text" name="fieldname" value="'.$conf->global->LDAP_MEMBER_FIELD_NAME.'">';
 print '</td><td>'.$langs->trans("LDAPFieldNameExample").'</td>';
-print '<td class="right"><input type="radio" name="key" value="LDAP_MEMBER_FIELD_NAME"'.(($conf->global->LDAP_KEY_MEMBERS && $conf->global->LDAP_KEY_MEMBERS==$conf->global->LDAP_MEMBER_FIELD_NAME)?' checked':'')."></td>";
+print '<td class="right"><input type="radio" name="key" value="LDAP_MEMBER_FIELD_NAME"'.(($conf->global->LDAP_KEY_MEMBERS && $conf->global->LDAP_KEY_MEMBERS == $conf->global->LDAP_MEMBER_FIELD_NAME) ? ' checked' : '')."></td>";
 print '</tr>';
 
 // Firstname
@@ -197,14 +197,14 @@ print '</tr>';
 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldLoginUnix").'</td><td>';
 print '<input size="25" type="text" name="fieldlogin" value="'.$conf->global->LDAP_MEMBER_FIELD_LOGIN.'">';
 print '</td><td>'.$langs->trans("LDAPFieldLoginExample").'</td>';
-print '<td class="right"><input type="radio" name="key" value="LDAP_MEMBER_FIELD_LOGIN"'.(($conf->global->LDAP_KEY_MEMBERS && $conf->global->LDAP_KEY_MEMBERS==$conf->global->LDAP_MEMBER_FIELD_LOGIN)?' checked':'')."></td>";
+print '<td class="right"><input type="radio" name="key" value="LDAP_MEMBER_FIELD_LOGIN"'.(($conf->global->LDAP_KEY_MEMBERS && $conf->global->LDAP_KEY_MEMBERS == $conf->global->LDAP_MEMBER_FIELD_LOGIN) ? ' checked' : '')."></td>";
 print '</tr>';
 
 // Login samba
 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldLoginSamba").'</td><td>';
 print '<input size="25" type="text" name="fieldloginsamba" value="'.$conf->global->LDAP_MEMBER_FIELD_LOGIN_SAMBA.'">';
 print '</td><td>'.$langs->trans("LDAPFieldLoginSambaExample").'</td>';
-print '<td class="right"><input type="radio" name="key" value="LDAP_MEMBER_FIELD_LOGIN_SAMBA"'.(($conf->global->LDAP_KEY_MEMBERS && $conf->global->LDAP_KEY_MEMBERS==$conf->global->LDAP_MEMBER_FIELD_LOGIN_SAMBA)?' checked':'')."></td>";
+print '<td class="right"><input type="radio" name="key" value="LDAP_MEMBER_FIELD_LOGIN_SAMBA"'.(($conf->global->LDAP_KEY_MEMBERS && $conf->global->LDAP_KEY_MEMBERS == $conf->global->LDAP_MEMBER_FIELD_LOGIN_SAMBA) ? ' checked' : '')."></td>";
 print '</tr>';
 
 // Password not crypted
@@ -225,7 +225,7 @@ print '</tr>';
 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldMail").'</td><td>';
 print '<input size="25" type="text" name="fieldmail" value="'.$conf->global->LDAP_MEMBER_FIELD_MAIL.'">';
 print '</td><td>'.$langs->trans("LDAPFieldMailExample").'</td>';
-print '<td class="right"><input type="radio" name="key" value="LDAP_MEMBER_FIELD_MAIL"'.(($conf->global->LDAP_KEY_MEMBERS && $conf->global->LDAP_KEY_MEMBERS==$conf->global->LDAP_MEMBER_FIELD_MAIL)?' checked':'')."></td>";
+print '<td class="right"><input type="radio" name="key" value="LDAP_MEMBER_FIELD_MAIL"'.(($conf->global->LDAP_KEY_MEMBERS && $conf->global->LDAP_KEY_MEMBERS == $conf->global->LDAP_MEMBER_FIELD_MAIL) ? ' checked' : '')."></td>";
 print '</tr>';
 
 // Phone pro
@@ -379,13 +379,13 @@ print '</form>';
 /*
  * Test de la connexion
  */
-if (! empty($conf->global->LDAP_MEMBER_ACTIVE))
+if (!empty($conf->global->LDAP_MEMBER_ACTIVE))
 {
-	$butlabel=$langs->trans("LDAPTestSynchroMember");
-	$testlabel='testmember';
-	$key=$conf->global->LDAP_KEY_MEMBERS;
-	$dn=$conf->global->LDAP_MEMBER_DN;
-	$objectclass=$conf->global->LDAP_MEMBER_OBJECT_CLASS;
+	$butlabel = $langs->trans("LDAPTestSynchroMember");
+	$testlabel = 'testmember';
+	$key = $conf->global->LDAP_KEY_MEMBERS;
+	$dn = $conf->global->LDAP_MEMBER_DN;
+	$objectclass = $conf->global->LDAP_MEMBER_OBJECT_CLASS;
 
 	show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass);
 }
@@ -395,21 +395,21 @@ if (function_exists("ldap_connect"))
 	if ($_GET["action"] == 'testmember')
 	{
 		// Creation objet
-		$object=new Adherent($db);
+		$object = new Adherent($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);
 
-			$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)
 			{

+ 72 - 72
htdocs/admin/ldap_users.php

@@ -48,44 +48,44 @@ $action = GETPOST('action', 'aZ09');
 
 if ($action == 'setvalue' && $user->admin)
 {
-	$error=0;
+	$error = 0;
 	$db->begin();
 
-	if (! dolibarr_set_const($db, 'LDAP_USER_DN', GETPOST("user"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_USER_OBJECT_CLASS', GETPOST("objectclass"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_FILTER_CONNECTION', GETPOST("filterconnection"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_FIELD_FULLNAME', GETPOST("fieldfullname"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_FIELD_LOGIN', GETPOST("fieldlogin"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_FIELD_LOGIN_SAMBA', GETPOST("fieldloginsamba"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_FIELD_PASSWORD', GETPOST("fieldpassword"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_FIELD_PASSWORD_CRYPTED', GETPOST("fieldpasswordcrypted"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_FIELD_NAME', GETPOST("fieldname"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_FIELD_FIRSTNAME', GETPOST("fieldfirstname"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_FIELD_MAIL', GETPOST("fieldmail"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_FIELD_PHONE', GETPOST("fieldphone"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_FIELD_MOBILE', GETPOST("fieldmobile"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_FIELD_SKYPE', GETPOST("fieldskype"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_FIELD_FAX', GETPOST("fieldfax"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_FIELD_COMPANY', GETPOST("fieldcompany"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_FIELD_ADDRESS', GETPOST("fieldaddress"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_FIELD_ZIP', GETPOST("fieldzip"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_FIELD_TOWN', GETPOST("fieldtown"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_FIELD_COUNTRY', GETPOST("fieldcountry"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_FIELD_DESCRIPTION', GETPOST("fielddescription"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_FIELD_SID', GETPOST("fieldsid"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_FIELD_TITLE', GETPOST("fieldtitle"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_FIELD_GROUPID', GETPOST("fieldgroupid"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_FIELD_USERID', GETPOST("fielduserid"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_FIELD_HOMEDIRECTORY', GETPOST("fieldhomedirectory"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_FIELD_HOMEDIRECTORYPREFIX', GETPOST("fieldhomedirectoryprefix"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_USER_DN', GETPOST("user"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_USER_OBJECT_CLASS', GETPOST("objectclass"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_FILTER_CONNECTION', GETPOST("filterconnection"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_FIELD_FULLNAME', GETPOST("fieldfullname"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_FIELD_LOGIN', GETPOST("fieldlogin"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_FIELD_LOGIN_SAMBA', GETPOST("fieldloginsamba"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_FIELD_PASSWORD', GETPOST("fieldpassword"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_FIELD_PASSWORD_CRYPTED', GETPOST("fieldpasswordcrypted"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_FIELD_NAME', GETPOST("fieldname"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_FIELD_FIRSTNAME', GETPOST("fieldfirstname"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_FIELD_MAIL', GETPOST("fieldmail"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_FIELD_PHONE', GETPOST("fieldphone"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_FIELD_MOBILE', GETPOST("fieldmobile"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_FIELD_SKYPE', GETPOST("fieldskype"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_FIELD_FAX', GETPOST("fieldfax"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_FIELD_COMPANY', GETPOST("fieldcompany"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_FIELD_ADDRESS', GETPOST("fieldaddress"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_FIELD_ZIP', GETPOST("fieldzip"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_FIELD_TOWN', GETPOST("fieldtown"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_FIELD_COUNTRY', GETPOST("fieldcountry"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_FIELD_DESCRIPTION', GETPOST("fielddescription"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_FIELD_SID', GETPOST("fieldsid"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_FIELD_TITLE', GETPOST("fieldtitle"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_FIELD_GROUPID', GETPOST("fieldgroupid"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_FIELD_USERID', GETPOST("fielduserid"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_FIELD_HOMEDIRECTORY', GETPOST("fieldhomedirectory"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_FIELD_HOMEDIRECTORYPREFIX', GETPOST("fieldhomedirectoryprefix"), '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_USERS', $valkey, 'chaine', 0, '', $conf->entity)) $error++;
+	$valkey = '';
+	$key = GETPOST("key");
+	if ($key) $valkey = $conf->global->$key;
+	if (!dolibarr_set_const($db, 'LDAP_KEY_USERS', $valkey, 'chaine', 0, '', $conf->entity)) $error++;
 
-	if (! $error)
+	if (!$error)
 	{
 		$db->commit();
 		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
@@ -103,17 +103,17 @@ if ($action == 'setvalue' && $user->admin)
  * Visu
  */
 
-$form=new Form($db);
+$form = new Form($db);
 
 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');
 }
@@ -170,35 +170,35 @@ print "</tr>\n";
 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldFullname").'</td><td>';
 print '<input size="25" type="text" name="fieldfullname" value="'.$conf->global->LDAP_FIELD_FULLNAME.'">';
 print '</td><td>'.$langs->trans("LDAPFieldFullnameExample").'</td>';
-print '<td class="right"><input type="radio" name="key" value="LDAP_FIELD_FULLNAME"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_FULLNAME)?' checked':'')."></td>";
+print '<td class="right"><input type="radio" name="key" value="LDAP_FIELD_FULLNAME"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS == $conf->global->LDAP_FIELD_FULLNAME) ? ' checked' : '')."></td>";
 print '</tr>';
 
 // Name
 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldName").'</td><td>';
 print '<input size="25" type="text" name="fieldname" value="'.$conf->global->LDAP_FIELD_NAME.'">';
 print '</td><td>'.$langs->trans("LDAPFieldNameExample").'</td>';
-print '<td class="right"><input type="radio" name="key" value="LDAP_FIELD_NAME"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_NAME)?' checked':'')."></td>";
+print '<td class="right"><input type="radio" name="key" value="LDAP_FIELD_NAME"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS == $conf->global->LDAP_FIELD_NAME) ? ' checked' : '')."></td>";
 print '</tr>';
 
 // Firstname
 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldFirstName").'</td><td>';
 print '<input size="25" type="text" name="fieldfirstname" value="'.$conf->global->LDAP_FIELD_FIRSTNAME.'">';
 print '</td><td>'.$langs->trans("LDAPFieldFirstNameExample").'</td>';
-print '<td class="right"><input type="radio" name="key" value="LDAP_FIELD_FIRSTNAME"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_FIRSTNAME)?' checked':'')."></td>";
+print '<td class="right"><input type="radio" name="key" value="LDAP_FIELD_FIRSTNAME"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS == $conf->global->LDAP_FIELD_FIRSTNAME) ? ' checked' : '')."></td>";
 print '</tr>';
 
 // Login unix
 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldLoginUnix").'</td><td>';
 print '<input size="25" type="text" name="fieldlogin" value="'.$conf->global->LDAP_FIELD_LOGIN.'">';
 print '</td><td>'.$langs->trans("LDAPFieldLoginExample").'</td>';
-print '<td class="right"><input type="radio" name="key" value="LDAP_FIELD_LOGIN"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_LOGIN)?' checked':'')."></td>";
+print '<td class="right"><input type="radio" name="key" value="LDAP_FIELD_LOGIN"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS == $conf->global->LDAP_FIELD_LOGIN) ? ' checked' : '')."></td>";
 print '</tr>';
 
 // Login samba
 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldLoginSamba").'</td><td>';
 print '<input size="25" type="text" name="fieldloginsamba" value="'.$conf->global->LDAP_FIELD_LOGIN_SAMBA.'">';
 print '</td><td>'.$langs->trans("LDAPFieldLoginSambaExample").'</td>';
-print '<td class="right"><input type="radio" name="key" value="LDAP_FIELD_LOGIN_SAMBA"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_LOGIN_SAMBA)?' checked':'')."></td>";
+print '<td class="right"><input type="radio" name="key" value="LDAP_FIELD_LOGIN_SAMBA"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS == $conf->global->LDAP_FIELD_LOGIN_SAMBA) ? ' checked' : '')."></td>";
 print '</tr>';
 
 // Password not crypted
@@ -219,35 +219,35 @@ print '</tr>';
 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldMail").'</td><td>';
 print '<input size="25" type="text" name="fieldmail" value="'.$conf->global->LDAP_FIELD_MAIL.'">';
 print '</td><td>'.$langs->trans("LDAPFieldMailExample").'</td>';
-print '<td class="right"><input type="radio" name="key" value="LDAP_FIELD_MAIL"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_MAIL)?' checked':'')."></td>";
+print '<td class="right"><input type="radio" name="key" value="LDAP_FIELD_MAIL"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS == $conf->global->LDAP_FIELD_MAIL) ? ' checked' : '')."></td>";
 print '</tr>';
 
 // Phone
 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldPhone").'</td><td>';
 print '<input size="25" type="text" name="fieldphone" value="'.$conf->global->LDAP_FIELD_PHONE.'">';
 print '</td><td>'.$langs->trans("LDAPFieldPhoneExample").'</td>';
-print '<td class="right"><input type="radio" name="key" value="LDAP_FIELD_PHONE"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_PHONE)?' checked':'')."></td>";
+print '<td class="right"><input type="radio" name="key" value="LDAP_FIELD_PHONE"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS == $conf->global->LDAP_FIELD_PHONE) ? ' checked' : '')."></td>";
 print '</tr>';
 
 // Mobile
 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldMobile").'</td><td>';
 print '<input size="25" type="text" name="fieldmobile" value="'.$conf->global->LDAP_FIELD_MOBILE.'">';
 print '</td><td>'.$langs->trans("LDAPFieldMobileExample").'</td>';
-print '<td class="right"><input type="radio" name="key" value="LDAP_FIELD_MOBILE"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_MOBILE)?' checked':'')."></td>";
+print '<td class="right"><input type="radio" name="key" value="LDAP_FIELD_MOBILE"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS == $conf->global->LDAP_FIELD_MOBILE) ? ' checked' : '')."></td>";
 print '</tr>';
 
 // Skype
 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldSkype").'</td><td>';
 print '<input size="25" type="text" name="fieldskype" value="'.$conf->global->LDAP_FIELD_SKYPE.'">';
 print '</td><td>'.$langs->trans("LDAPFieldSkypeExample").'</td>';
-print '<td class="right"><input type="radio" name="key" value="LDAP_FIELD_SKYPE"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_SKYPE)?' checked':'')."></td>";
+print '<td class="right"><input type="radio" name="key" value="LDAP_FIELD_SKYPE"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS == $conf->global->LDAP_FIELD_SKYPE) ? ' checked' : '')."></td>";
 print '</tr>';
 
 // Fax
 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldFax").'</td><td>';
 print '<input size="25" type="text" name="fieldfax" value="'.$conf->global->LDAP_FIELD_FAX.'">';
 print '</td><td>'.$langs->trans("LDAPFieldFaxExample").'</td>';
-print '<td class="right"><input type="radio" name="key" value="LDAP_FIELD_FAX"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_FAX)?' checked':'')."></td>";
+print '<td class="right"><input type="radio" name="key" value="LDAP_FIELD_FAX"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS == $conf->global->LDAP_FIELD_FAX) ? ' checked' : '')."></td>";
 print '</tr>';
 
 // Company
@@ -303,7 +303,7 @@ print '</tr>';
 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldSid").'</td><td>';
 print '<input size="25" type="text" name="fieldsid" value="'.$conf->global->LDAP_FIELD_SID.'">';
 print '</td><td>'.$langs->trans("LDAPFieldSidExample").'</td>';
-print '<td class="right"><input type="radio" name="key" value="LDAP_FIELD_SID"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_SID)?' checked':'')."></td>";
+print '<td class="right"><input type="radio" name="key" value="LDAP_FIELD_SID"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS == $conf->global->LDAP_FIELD_SID) ? ' checked' : '')."></td>";
 print '</tr>';
 
 // Group id
@@ -350,21 +350,21 @@ print '</form>';
  */
 if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap')
 {
-	$butlabel=$langs->trans("LDAPTestSynchroUser");
-	$testlabel='testuser';
-	$key=$conf->global->LDAP_KEY_USERS;
-	$dn=$conf->global->LDAP_USER_DN;
-	$objectclass=$conf->global->LDAP_USER_OBJECT_CLASS;
+	$butlabel = $langs->trans("LDAPTestSynchroUser");
+	$testlabel = 'testuser';
+	$key = $conf->global->LDAP_KEY_USERS;
+	$dn = $conf->global->LDAP_USER_DN;
+	$objectclass = $conf->global->LDAP_USER_OBJECT_CLASS;
 
 	show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass);
 }
 elseif ($conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr')
 {
-	$butlabel=$langs->trans("LDAPTestSearch");
-	$testlabel='testsearchuser';
-	$key=$conf->global->LDAP_KEY_USERS;
-	$dn=$conf->global->LDAP_USER_DN;
-	$objectclass=$conf->global->LDAP_USER_OBJECT_CLASS;
+	$butlabel = $langs->trans("LDAPTestSearch");
+	$testlabel = 'testsearchuser';
+	$key = $conf->global->LDAP_KEY_USERS;
+	$dn = $conf->global->LDAP_USER_DN;
+	$objectclass = $conf->global->LDAP_USER_OBJECT_CLASS;
 	show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass);
 }
 
@@ -373,23 +373,23 @@ if (function_exists("ldap_connect"))
 	if ($action == 'testuser')
 	{
 		// Creation objet
-		$object=new User($db);
+		$object = new User($db);
 		$object->initAsSpecimen();
 
 		// TODO Mutualize code following with other ldap_xxxx.php pages
 
 		// 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);
 
-			$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)
 			{
@@ -423,14 +423,14 @@ if (function_exists("ldap_connect"))
 	if ($action == 'testsearchuser')
 	{
 		// Creation objet
-		$object=new User($db);
+		$object = new User($db);
 		$object->initAsSpecimen();
 
 		// TODO Mutualize code following with other ldap_xxxx.php pages
 
 		// Test synchro
-		$ldap=new Ldap();
-		$result=$ldap->connect_bind();
+		$ldap = new Ldap();
+		$result = $ldap->connect_bind();
 
 		if ($result > 0)
 		{
@@ -454,7 +454,7 @@ if (function_exists("ldap_connect"))
 			);
 
 			// Remove from required_fields all entries not configured in LDAP (empty) and duplicated
-			$required_fields=array_unique(array_values(array_filter($required_fields, "dol_validElement")));
+			$required_fields = array_unique(array_values(array_filter($required_fields, "dol_validElement")));
 
 			// Get from LDAP database an array of results
 			$ldapusers = $ldap->getRecords('*', $conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, $required_fields, 1);
@@ -462,16 +462,16 @@ if (function_exists("ldap_connect"))
 
 			if (is_array($ldapusers))
 			{
-				$liste=array();
+				$liste = array();
 				foreach ($ldapusers as $key => $ldapuser)
 				{
 					// Define the label string for this user
-					$label='';
+					$label = '';
 					foreach ($required_fields as $value)
 					{
 						if ($value)
 						{
-							$label.=$value."=".$ldapuser[$value]." ";
+							$label .= $value."=".$ldapuser[$value]." ";
 						}
 					}
 					$liste[$key] = $label;

+ 50 - 50
htdocs/admin/limits.php

@@ -29,20 +29,20 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
 // Load translation files required by the page
 $langs->loadLangs(array('companies', 'products', 'admin'));
 
-if (! $user->admin) accessforbidden();
+if (!$user->admin) accessforbidden();
 
 $action = GETPOST('action', 'alpha');
 $currencycode = GETPOST('currencycode', 'alpha');
 
-$mainmaxdecimalsunit = 'MAIN_MAX_DECIMALS_UNIT'.(! empty($currencycode)?'_'.$currencycode:'');
-$mainmaxdecimalstot = 'MAIN_MAX_DECIMALS_TOT'.(! empty($currencycode)?'_'.$currencycode:'');
-$mainmaxdecimalsshown = 'MAIN_MAX_DECIMALS_SHOWN'.(! empty($currencycode)?'_'.$currencycode:'');
-$mainroundingruletot = 'MAIN_ROUNDING_RULE_TOT'.(! empty($currencycode)?'_'.$currencycode:'');
+$mainmaxdecimalsunit = 'MAIN_MAX_DECIMALS_UNIT'.(!empty($currencycode) ? '_'.$currencycode : '');
+$mainmaxdecimalstot = 'MAIN_MAX_DECIMALS_TOT'.(!empty($currencycode) ? '_'.$currencycode : '');
+$mainmaxdecimalsshown = 'MAIN_MAX_DECIMALS_SHOWN'.(!empty($currencycode) ? '_'.$currencycode : '');
+$mainroundingruletot = 'MAIN_ROUNDING_RULE_TOT'.(!empty($currencycode) ? '_'.$currencycode : '');
 
 if ($action == 'update')
 {
-	$error=0;
-	$MAXDEC=8;
+	$error = 0;
+	$MAXDEC = 8;
 	if ($_POST[$mainmaxdecimalsunit] > $MAXDEC
 	|| $_POST[$mainmaxdecimalstot] > $MAXDEC
 	|| $_POST[$mainmaxdecimalsshown] > $MAXDEC)
@@ -51,7 +51,7 @@ if ($action == 'update')
 	    setEventMessages($langs->trans("ErrorDecimalLargerThanAreForbidden", $MAXDEC), null, 'errors');
     }
 
-    if ($_POST[$mainmaxdecimalsunit].(! empty($currencycode)?'_'.$currencycode:'')  < 0
+    if ($_POST[$mainmaxdecimalsunit].(!empty($currencycode) ? '_'.$currencycode : '') < 0
     || $_POST[$mainmaxdecimalstot] < 0
     || $_POST[$mainmaxdecimalsshown] < 0)
     {
@@ -70,7 +70,7 @@ if ($action == 'update')
         }
     }
 
-    if (! $error)
+    if (!$error)
     {
     	dolibarr_set_const($db, $mainmaxdecimalsunit, $_POST[$mainmaxdecimalsunit], 'chaine', 0, '', $conf->entity);
     	dolibarr_set_const($db, $mainmaxdecimalstot, $_POST[$mainmaxdecimalstot], 'chaine', 0, '', $conf->entity);
@@ -78,7 +78,7 @@ if ($action == 'update')
 
     	dolibarr_set_const($db, $mainroundingruletot, $_POST[$mainroundingruletot], 'chaine', 0, '', $conf->entity);
 
-        header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup".(! empty($currencycode)?'&currencycode='.$currencycode:''));
+        header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup".(!empty($currencycode) ? '&currencycode='.$currencycode : ''));
         exit;
     }
 }
@@ -88,22 +88,22 @@ if ($action == 'update')
  * View
  */
 
-$form=new Form($db);
+$form = new Form($db);
 
 llxHeader();
 
 print load_fiche_titre($langs->trans("LimitsSetup"), '', 'title_setup');
 
-$currencycode = (! empty($currencycode)?$currencycode:$conf->currency);
-$aCurrencies = array($conf->currency);	// Default currency always first position
+$currencycode = (!empty($currencycode) ? $currencycode : $conf->currency);
+$aCurrencies = array($conf->currency); // Default currency always first position
 
-if (! empty($conf->multicurrency->enabled) && ! empty($conf->global->MULTICURRENCY_USE_LIMIT_BY_CURRENCY))
+if (!empty($conf->multicurrency->enabled) && !empty($conf->global->MULTICURRENCY_USE_LIMIT_BY_CURRENCY))
 {
 	require_once DOL_DOCUMENT_ROOT.'/core/lib/multicurrency.lib.php';
 
 	$sql = 'SELECT rowid, code FROM '.MAIN_DB_PREFIX.'multicurrency';
-	$sql.= ' WHERE entity = '.$conf->entity;
-	$sql.= ' AND code != "'.$conf->currency.'"';	// Default currency always first position
+	$sql .= ' WHERE entity = '.$conf->entity;
+	$sql .= ' AND code != "'.$conf->currency.'"'; // Default currency always first position
 	$resql = $db->query($sql);
 	if ($resql)
 	{
@@ -113,7 +113,7 @@ if (! empty($conf->multicurrency->enabled) && ! empty($conf->global->MULTICURREN
 		}
 	}
 
-	if (! empty($aCurrencies) && count($aCurrencies) > 1)
+	if (!empty($aCurrencies) && count($aCurrencies) > 1)
 	{
 		$head = multicurrencyLimitPrepareHead($aCurrencies);
 		dol_fiche_head($head, $currencycode, '', -1, "multicurrency");
@@ -128,7 +128,7 @@ if ($action == 'edit')
     print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
     print '<input type="hidden" name="token" value="'.newToken().'">';
     print '<input type="hidden" name="action" value="update">';
-    if (! empty($conf->multicurrency->enabled) && ! empty($conf->global->MULTICURRENCY_USE_LIMIT_BY_CURRENCY)) {
+    if (!empty($conf->multicurrency->enabled) && !empty($conf->global->MULTICURRENCY_USE_LIMIT_BY_CURRENCY)) {
     	print '<input type="hidden" name="currencycode" value="'.$currencycode.'">';
     }
 
@@ -139,18 +139,18 @@ if ($action == 'edit')
 
     print '<tr class="oddeven"><td>';
     print $form->textwithpicto($langs->trans("MAIN_MAX_DECIMALS_UNIT"), $langs->trans("ParameterActiveForNextInputOnly"));
-    print '</td><td><input class="flat" name="'.$mainmaxdecimalsunit.'" size="3" value="'.(isset($conf->global->$mainmaxdecimalsunit)?$conf->global->$mainmaxdecimalsunit:$conf->global->MAIN_MAX_DECIMALS_UNIT).'"></td></tr>';
+    print '</td><td><input class="flat" name="'.$mainmaxdecimalsunit.'" size="3" value="'.(isset($conf->global->$mainmaxdecimalsunit) ? $conf->global->$mainmaxdecimalsunit : $conf->global->MAIN_MAX_DECIMALS_UNIT).'"></td></tr>';
 
     print '<tr class="oddeven"><td>';
     print $form->textwithpicto($langs->trans("MAIN_MAX_DECIMALS_TOT"), $langs->trans("ParameterActiveForNextInputOnly"));
-    print '</td><td><input class="flat" name="'.$mainmaxdecimalstot.'" size="3" value="'.(isset($conf->global->$mainmaxdecimalstot)?$conf->global->$mainmaxdecimalstot:$conf->global->MAIN_MAX_DECIMALS_TOT).'"></td></tr>';
+    print '</td><td><input class="flat" name="'.$mainmaxdecimalstot.'" size="3" value="'.(isset($conf->global->$mainmaxdecimalstot) ? $conf->global->$mainmaxdecimalstot : $conf->global->MAIN_MAX_DECIMALS_TOT).'"></td></tr>';
 
     print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAX_DECIMALS_SHOWN").'</td>';
-    print '<td><input class="flat" name="'.$mainmaxdecimalsshown.'" size="3" value="'.(isset($conf->global->$mainmaxdecimalsshown)?$conf->global->$mainmaxdecimalsshown:$conf->global->MAIN_MAX_DECIMALS_SHOWN).'"></td></tr>';
+    print '<td><input class="flat" name="'.$mainmaxdecimalsshown.'" size="3" value="'.(isset($conf->global->$mainmaxdecimalsshown) ? $conf->global->$mainmaxdecimalsshown : $conf->global->MAIN_MAX_DECIMALS_SHOWN).'"></td></tr>';
 
     print '<tr class="oddeven"><td>';
     print $form->textwithpicto($langs->trans("MAIN_ROUNDING_RULE_TOT"), $langs->trans("ParameterActiveForNextInputOnly"));
-    print '</td><td><input class="flat" name="'.$mainroundingruletot.'" size="3" value="'.(isset($conf->global->$mainroundingruletot)?$conf->global->$mainroundingruletot:$conf->global->MAIN_ROUNDING_RULE_TOT).'"></td></tr>';
+    print '</td><td><input class="flat" name="'.$mainroundingruletot.'" size="3" value="'.(isset($conf->global->$mainroundingruletot) ? $conf->global->$mainroundingruletot : $conf->global->MAIN_ROUNDING_RULE_TOT).'"></td></tr>';
 
     print '</table>';
 
@@ -170,29 +170,29 @@ else
 
     print '<tr class="oddeven"><td>';
     print $form->textwithpicto($langs->trans("MAIN_MAX_DECIMALS_UNIT"), $langs->trans("ParameterActiveForNextInputOnly"));
-    print '</td><td align="right">'.(isset($conf->global->$mainmaxdecimalsunit)?$conf->global->$mainmaxdecimalsunit:$conf->global->MAIN_MAX_DECIMALS_UNIT).'</td></tr>';
+    print '</td><td align="right">'.(isset($conf->global->$mainmaxdecimalsunit) ? $conf->global->$mainmaxdecimalsunit : $conf->global->MAIN_MAX_DECIMALS_UNIT).'</td></tr>';
 
     print '<tr class="oddeven"><td>';
     print $form->textwithpicto($langs->trans("MAIN_MAX_DECIMALS_TOT"), $langs->trans("ParameterActiveForNextInputOnly"));
-    print '</td><td align="right">'.(isset($conf->global->$mainmaxdecimalstot)?$conf->global->$mainmaxdecimalstot:$conf->global->MAIN_MAX_DECIMALS_TOT).'</td></tr>';
+    print '</td><td align="right">'.(isset($conf->global->$mainmaxdecimalstot) ? $conf->global->$mainmaxdecimalstot : $conf->global->MAIN_MAX_DECIMALS_TOT).'</td></tr>';
 
     print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAX_DECIMALS_SHOWN").'</td>';
-    print '<td align="right">'.(isset($conf->global->$mainmaxdecimalsshown)?$conf->global->$mainmaxdecimalsshown:$conf->global->MAIN_MAX_DECIMALS_SHOWN).'</td></tr>';
+    print '<td align="right">'.(isset($conf->global->$mainmaxdecimalsshown) ? $conf->global->$mainmaxdecimalsshown : $conf->global->MAIN_MAX_DECIMALS_SHOWN).'</td></tr>';
 
     print '<tr class="oddeven"><td>';
     print $form->textwithpicto($langs->trans("MAIN_ROUNDING_RULE_TOT"), $langs->trans("ParameterActiveForNextInputOnly"));
-    print '</td><td align="right">'.(isset($conf->global->$mainroundingruletot)?$conf->global->$mainroundingruletot:$conf->global->MAIN_ROUNDING_RULE_TOT).'</td></tr>';
+    print '</td><td align="right">'.(isset($conf->global->$mainroundingruletot) ? $conf->global->$mainroundingruletot : $conf->global->MAIN_ROUNDING_RULE_TOT).'</td></tr>';
 
     print '</table>';
 
     print '<div class="tabsAction">';
-    print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit'.(! empty($currencycode)?'&currencycode='.$currencycode:'').'">'.$langs->trans("Modify").'</a>';
+    print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit'.(!empty($currencycode) ? '&currencycode='.$currencycode : '').'">'.$langs->trans("Modify").'</a>';
     print '</div>';
 }
 
-if (! empty($conf->multicurrency->enabled) && ! empty($conf->global->MULTICURRENCY_USE_LIMIT_BY_CURRENCY))
+if (!empty($conf->multicurrency->enabled) && !empty($conf->global->MULTICURRENCY_USE_LIMIT_BY_CURRENCY))
 {
-	if (! empty($aCurrencies) && count($aCurrencies) > 1)
+	if (!empty($aCurrencies) && count($aCurrencies) > 1)
 	{
 		dol_fiche_end();
 	}
@@ -201,7 +201,7 @@ if (! empty($conf->multicurrency->enabled) && ! empty($conf->global->MULTICURREN
 if (empty($mysoc->country_code))
 {
 	$langs->load("errors");
-	$warnpicto=img_warning($langs->trans("WarningMandatorySetupNotComplete"));
+	$warnpicto = img_warning($langs->trans("WarningMandatorySetupNotComplete"));
 	print '<br><a href="'.DOL_URL_ROOT.'/admin/company.php?mainmenu=home">'.$warnpicto.' '.$langs->trans("WarningMandatorySetupNotComplete").'</a>';
 }
 else
@@ -210,35 +210,35 @@ else
 	print load_fiche_titre($langs->trans("ExamplesWithCurrentSetup"), '', '');
 
 	// Always show vat rates with vat 0
-	$s=2/7;$qty=1;$vat=0;
-	$tmparray=calcul_price_total(1, $qty*price2num($s, 'MU'), 0, $vat, 0, 0, 0, 'HT', 0, 0, $mysoc);
+	$s = 2 / 7; $qty = 1; $vat = 0;
+	$tmparray = calcul_price_total(1, $qty * price2num($s, 'MU'), 0, $vat, 0, 0, 0, 'HT', 0, 0, $mysoc);
 	print '<span class="opacitymedium">'.$langs->trans("UnitPriceOfProduct").":</span> ".price2num($s, 'MU');
 	print " x ".$langs->trans("Quantity").": ".$qty;
 	print " - ".$langs->trans("VAT").": ".$vat.'%';
 	print ' &nbsp; -> &nbsp; <span class="opacitymedium">'.$langs->trans("TotalPriceAfterRounding").":</span> ".$tmparray[0].' / '.$tmparray[1].' / '.$tmparray[2]."<br>\n";
 
-	$s=10/3;$qty=1;$vat=0;
-	$tmparray=calcul_price_total(1, $qty*price2num($s, 'MU'), 0, $vat, 0, 0, 0, 'HT', 0, 0, $mysoc);
+	$s = 10 / 3; $qty = 1; $vat = 0;
+	$tmparray = calcul_price_total(1, $qty * price2num($s, 'MU'), 0, $vat, 0, 0, 0, 'HT', 0, 0, $mysoc);
 	print '<span class="opacitymedium">'.$langs->trans("UnitPriceOfProduct").":</span> ".price2num($s, 'MU');
 	print " x ".$langs->trans("Quantity").": ".$qty;
 	print " - ".$langs->trans("VAT").": ".$vat.'%';
 	print ' &nbsp; -> &nbsp; <span class="opacitymedium">'.$langs->trans("TotalPriceAfterRounding").":</span> ".$tmparray[0].' / '.$tmparray[1].' / '.$tmparray[2]."<br>\n";
 
-	$s=10/3;$qty=2;$vat=0;
-	$tmparray=calcul_price_total(1, $qty*price2num($s, 'MU'), 0, $vat, 0, 0, 0, 'HT', 0, 0, $mysoc);
+	$s = 10 / 3; $qty = 2; $vat = 0;
+	$tmparray = calcul_price_total(1, $qty * price2num($s, 'MU'), 0, $vat, 0, 0, 0, 'HT', 0, 0, $mysoc);
 	print '<span class="opacitymedium">'.$langs->trans("UnitPriceOfProduct").":</span> ".price2num($s, 'MU');
 	print " x ".$langs->trans("Quantity").": ".$qty;
 	print " - ".$langs->trans("VAT").": ".$vat.'%';
 	print ' &nbsp; -> &nbsp; <span class="opacitymedium">'.$langs->trans("TotalPriceAfterRounding").":</span> ".$tmparray[0].' / '.$tmparray[1].' / '.$tmparray[2]."<br>\n";
 
 	// Add vat rates examples specific to country
-	$vat_rates=array();
+	$vat_rates = array();
 
-	$sql="SELECT taux as vat_rate";
-	$sql.=" FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c";
-	$sql.=" WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='".$mysoc->country_code."' AND t.taux <> 0";
-	$sql.=" ORDER BY t.taux ASC";
-	$resql=$db->query($sql);
+	$sql = "SELECT taux as vat_rate";
+	$sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c";
+	$sql .= " WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='".$mysoc->country_code."' AND t.taux <> 0";
+	$sql .= " ORDER BY t.taux ASC";
+	$resql = $db->query($sql);
 	if ($resql)
 	{
 	    $num = $db->num_rows($resql);
@@ -255,12 +255,12 @@ else
 
 	if (count($vat_rates))
 	{
-	    foreach($vat_rates as $vat)
+	    foreach ($vat_rates as $vat)
 	    {
-	        for ($qty=1; $qty<=2; $qty++)
+	        for ($qty = 1; $qty <= 2; $qty++)
 	        {
-	            $s=10/3;
-	            $tmparray=calcul_price_total(1, $qty*price2num($s, 'MU'), 0, $vat, 0, 0, 0, 'HT', 0, 0, $mysoc);
+	            $s = 10 / 3;
+	            $tmparray = calcul_price_total(1, $qty * price2num($s, 'MU'), 0, $vat, 0, 0, 0, 'HT', 0, 0, $mysoc);
 	            print '<span class="opacitymedium">'.$langs->trans("UnitPriceOfProduct").":</span> ".price2num($s, 'MU');
 	            print " x ".$langs->trans("Quantity").": ".$qty;
 	            print " - ".$langs->trans("VAT").": ".$vat.'%';
@@ -274,15 +274,15 @@ else
 	    // This example must be kept for test purpose with current value because value used (2/7, 10/3, and vat 0, 10)
 	    // were calculated to show all possible cases of rounding. If we change this, examples becomes useless or show the same rounding rule.
 
-	    $s=10/3;$qty=1;$vat=10;
-	    $tmparray=calcul_price_total(1, $qty*price2num($s, 'MU'), 0, $vat, 0, 0, 0, 'HT', 0, 0, $mysoc);
+	    $s = 10 / 3; $qty = 1; $vat = 10;
+	    $tmparray = calcul_price_total(1, $qty * price2num($s, 'MU'), 0, $vat, 0, 0, 0, 'HT', 0, 0, $mysoc);
 	    print '<span class="opacitymedium">'.$langs->trans("UnitPriceOfProduct").":</span> ".price2num($s, 'MU');
 	    print " x ".$langs->trans("Quantity").": ".$qty;
 	    print " - ".$langs->trans("VAT").": ".$vat.'%';
 	    print ' &nbsp; -> &nbsp; <span class="opacitymedium">'.$langs->trans("TotalPriceAfterRounding").": ".$tmparray[0].' / '.$tmparray[1].' / '.$tmparray[2]."<br>\n";
 
-	    $s=10/3;$qty=2;$vat=10;
-	    $tmparray=calcul_price_total(1, $qty*price2num($s, 'MU'), 0, $vat, 0, 0, 0, 'HT', 0, 0, $mysoc);
+	    $s = 10 / 3; $qty = 2; $vat = 10;
+	    $tmparray = calcul_price_total(1, $qty * price2num($s, 'MU'), 0, $vat, 0, 0, 0, 'HT', 0, 0, $mysoc);
 	    print '<span class="opacitymedium">'.$langs->trans("UnitPriceOfProduct").":</span> ".price2num($s, 'MU');
 	    print " x ".$langs->trans("Quantity").": ".$qty;
 	    print " - ".$langs->trans("VAT").": ".$vat.'%';

+ 9 - 9
htdocs/admin/livraison_extrafields.php

@@ -43,13 +43,13 @@ $extrafields = new ExtraFields($db);
 $form = new Form($db);
 
 // List of supported format
-$tmptype2label=ExtraFields::$type2label;
-$type2label=array('');
-foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
+$tmptype2label = ExtraFields::$type2label;
+$type2label = array('');
+foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val);
 
-$action=GETPOST('action', 'alpha');
-$attrname=GETPOST('attrname', 'alpha');
-$elementtype='livraison'; //Must be the $table_element of the class that manage extrafield
+$action = GETPOST('action', 'alpha');
+$attrname = GETPOST('attrname', 'alpha');
+$elementtype = 'livraison'; //Must be the $table_element of the class that manage extrafield
 
 if (!$user->admin) accessforbidden();
 
@@ -66,11 +66,11 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
  * View
  */
 
-$textobject=$langs->transnoentitiesnoconv("Receivings");
+$textobject = $langs->transnoentitiesnoconv("Receivings");
 
 llxHeader('', $langs->trans("SendingsSetup"));
 
-$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("SendingsSetup"), $linkback, 'title_setup');
 print "<br>\n";
 
@@ -111,7 +111,7 @@ if ($action == 'create')
 /* Edition of an optional field                                               */
 /*                                                                            */
 /* ************************************************************************** */
-if ($action == 'edit' && ! empty($attrname))
+if ($action == 'edit' && !empty($attrname))
 {
 	print "<br>";
 	print load_fiche_titre($langs->trans("FieldEdition", $attrname));

+ 9 - 9
htdocs/admin/livraisondet_extrafields.php

@@ -44,13 +44,13 @@ $extrafields = new ExtraFields($db);
 $form = new Form($db);
 
 // List of supported format
-$tmptype2label=ExtraFields::$type2label;
-$type2label=array('');
-foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
+$tmptype2label = ExtraFields::$type2label;
+$type2label = array('');
+foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val);
 
-$action=GETPOST('action', 'alpha');
-$attrname=GETPOST('attrname', 'alpha');
-$elementtype='livraisondet'; //Must be the $table_element of the class that manage extrafield
+$action = GETPOST('action', 'alpha');
+$attrname = GETPOST('attrname', 'alpha');
+$elementtype = 'livraisondet'; //Must be the $table_element of the class that manage extrafield
 
 if (!$user->admin) accessforbidden();
 
@@ -67,11 +67,11 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
  * View
  */
 
-$textobject=$langs->transnoentitiesnoconv("Receivings");
+$textobject = $langs->transnoentitiesnoconv("Receivings");
 
 llxHeader('', $langs->trans("SendingsSetup"));
 
-$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("SendingsSetup"), $linkback, 'title_setup');
 print "<br>\n";
 
@@ -112,7 +112,7 @@ if ($action == 'create')
 /* Edition of an optional field                                               */
 /*                                                                            */
 /* ************************************************************************** */
-if ($action == 'edit' && ! empty($attrname))
+if ($action == 'edit' && !empty($attrname))
 {
     print "<br>";
     print load_fiche_titre($langs->trans("FieldEdition", $attrname));

+ 15 - 15
htdocs/admin/mailing.php

@@ -50,18 +50,18 @@ if ($action == 'setvalue')
 	$checkread_key = GETPOST('MAILING_EMAIL_UNSUBSCRIBE_KEY', 'alpha');
 	$mailingdelay = GETPOST('MAILING_DELAY', 'int');
 
-	$res=dolibarr_set_const($db, "MAILING_EMAIL_FROM", $mailfrom, 'chaine', 0, '', $conf->entity);
-	if (! $res > 0) $error++;
-	$res=dolibarr_set_const($db, "MAILING_EMAIL_ERRORSTO", $mailerror, 'chaine', 0, '', $conf->entity);
-	if (! $res > 0) $error++;
-	$res=dolibarr_set_const($db, "MAILING_DELAY", $mailingdelay, 'chaine', 0, '', $conf->entity);
-	if (! $res > 0) $error++;
+	$res = dolibarr_set_const($db, "MAILING_EMAIL_FROM", $mailfrom, 'chaine', 0, '', $conf->entity);
+	if (!$res > 0) $error++;
+	$res = dolibarr_set_const($db, "MAILING_EMAIL_ERRORSTO", $mailerror, 'chaine', 0, '', $conf->entity);
+	if (!$res > 0) $error++;
+	$res = dolibarr_set_const($db, "MAILING_DELAY", $mailingdelay, 'chaine', 0, '', $conf->entity);
+	if (!$res > 0) $error++;
 
 	// Create temporary encryption key if nedded
-	$res=dolibarr_set_const($db, "MAILING_EMAIL_UNSUBSCRIBE_KEY", $checkread_key, 'chaine', 0, '', $conf->entity);
-	if (! $res > 0) $error++;
+	$res = dolibarr_set_const($db, "MAILING_EMAIL_UNSUBSCRIBE_KEY", $checkread_key, 'chaine', 0, '', $conf->entity);
+	if (!$res > 0) $error++;
 
-	if (! $error)
+	if (!$error)
 	{
 		$db->commit();
 		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
@@ -80,10 +80,10 @@ if ($action == 'setvalue')
 
 llxHeader('', $langs->trans("MailingSetup"));
 
-$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("MailingSetup"), $linkback, 'title_setup');
 
-if (! empty($conf->use_javascript_ajax))
+if (!empty($conf->use_javascript_ajax))
 {
 	print "\n".'<script type="text/javascript">';
 	print '$(document).ready(function () {
@@ -114,13 +114,13 @@ print "</tr>\n";
 print '<tr class="oddeven"><td>';
 print $langs->trans("MailingEMailFrom").'</td><td>';
 print '<input size="32" type="text" name="MAILING_EMAIL_FROM" value="'.$conf->global->MAILING_EMAIL_FROM.'">';
-if (!empty($conf->global->MAILING_EMAIL_FROM) && ! isValidEmail($conf->global->MAILING_EMAIL_FROM)) print ' '.img_warning($langs->trans("BadEMail"));
+if (!empty($conf->global->MAILING_EMAIL_FROM) && !isValidEmail($conf->global->MAILING_EMAIL_FROM)) print ' '.img_warning($langs->trans("BadEMail"));
 print '</td></tr>';
 
 print '<tr class="oddeven"><td>';
 print $langs->trans("MailingEMailError").'</td><td>';
 print '<input size="32" type="text" name="MAILING_EMAIL_ERRORSTO" value="'.$conf->global->MAILING_EMAIL_ERRORSTO.'">';
-if (!empty($conf->global->MAILING_EMAIL_ERRORSTO) && ! isValidEmail($conf->global->MAILING_EMAIL_ERRORSTO)) print ' '.img_warning($langs->trans("BadEMail"));
+if (!empty($conf->global->MAILING_EMAIL_ERRORSTO) && !isValidEmail($conf->global->MAILING_EMAIL_ERRORSTO)) print ' '.img_warning($langs->trans("BadEMail"));
 print '</td></tr>';
 
 print '<tr class="oddeven"><td>';
@@ -135,10 +135,10 @@ print '</td></tr>';
 print '<tr class="oddeven"><td>';
 print $langs->trans("ActivateCheckReadKey").'</td><td>';
 print '<input size="32" type="text" name="MAILING_EMAIL_UNSUBSCRIBE_KEY" id="MAILING_EMAIL_UNSUBSCRIBE_KEY" value="'.$conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY.'">';
-if (! empty($conf->use_javascript_ajax)) print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
+if (!empty($conf->use_javascript_ajax)) print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
 print '</td></tr>';
 
-if (!empty($conf->use_javascript_ajax) && $conf->global->MAIN_FEATURES_LEVEL >=1) {
+if (!empty($conf->use_javascript_ajax) && $conf->global->MAIN_FEATURES_LEVEL >= 1) {
 	print '<tr class="oddeven"><td>';
 	print $langs->trans("MailAdvTargetRecipients").'</td><td>';
 	print ajax_constantonoff('EMAILING_USE_ADVANCED_SELECTOR');

+ 32 - 32
htdocs/admin/mailman.php

@@ -35,10 +35,10 @@ require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
 // Load translation files required by the page
 $langs->loadLangs(array("admin", "members", "mailmanspip"));
 
-if (! $user->admin) accessforbidden();
+if (!$user->admin) accessforbidden();
 
 
-$type=array('yesno','texte','chaine');
+$type = array('yesno', 'texte', 'chaine');
 
 $action = GETPOST('action', 'aZ09');
 $testsubscribeemail = GETPOST("testsubscribeemail");
@@ -51,18 +51,18 @@ $testunsubscribeemail = GETPOST("testunsubscribeemail");
 // Action updated or added a constant
 if ($action == 'update' || $action == 'add')
 {
-	foreach($_POST['constname'] as $key => $val)
+	foreach ($_POST['constname'] as $key => $val)
 	{
-		$constname=$_POST["constname"][$key];
-		$constvalue=$_POST["constvalue"][$key];
-		$consttype=$_POST["consttype"][$key];
-		$constnote=$_POST["constnote"][$key];
-		$res=dolibarr_set_const($db, $constname, $constvalue, $type[$consttype], 0, $constnote, $conf->entity);
+		$constname = $_POST["constname"][$key];
+		$constvalue = $_POST["constvalue"][$key];
+		$consttype = $_POST["consttype"][$key];
+		$constnote = $_POST["constnote"][$key];
+		$res = dolibarr_set_const($db, $constname, $constvalue, $type[$consttype], 0, $constnote, $conf->entity);
 
-		if (! $res > 0) $error++;
+		if (!$res > 0) $error++;
 	}
 
- 	if (! $error)
+ 	if (!$error)
     {
         setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
     }
@@ -75,7 +75,7 @@ if ($action == 'update' || $action == 'add')
 // Action activation d'un sous module du module adherent
 if ($action == 'set')
 {
-    $result=dolibarr_set_const($db, $_GET["name"], $_GET["value"], '', 0, '', $conf->entity);
+    $result = dolibarr_set_const($db, $_GET["name"], $_GET["value"], '', 0, '', $conf->entity);
     if ($result < 0)
     {
         dol_print_error($db);
@@ -85,17 +85,17 @@ if ($action == 'set')
 // Action desactivation d'un sous module du module adherent
 if ($action == 'unset')
 {
-    $result=dolibarr_del_const($db, $_GET["name"], $conf->entity);
+    $result = dolibarr_del_const($db, $_GET["name"], $conf->entity);
     if ($result < 0)
     {
         dol_print_error($db);
     }
 }
 
-if (($action == 'testsubscribe' || $action == 'testunsubscribe') && ! empty($conf->global->ADHERENT_USE_MAILMAN))
+if (($action == 'testsubscribe' || $action == 'testunsubscribe') && !empty($conf->global->ADHERENT_USE_MAILMAN))
 {
-    $email=GETPOST($action.'email');
-    if (! isValidEmail($email))
+    $email = GETPOST($action.'email');
+    if (!isValidEmail($email))
     {
         $langs->load("errors");
         setEventMessages($langs->trans("ErrorBadEMail", $email), null, 'errors');
@@ -103,17 +103,17 @@ if (($action == 'testsubscribe' || $action == 'testunsubscribe') && ! empty($con
     else
     {
         include_once DOL_DOCUMENT_ROOT.'/mailmanspip/class/mailmanspip.class.php';
-        $mailmanspip=new MailmanSpip($db);
+        $mailmanspip = new MailmanSpip($db);
 
-        $object=new stdClass();
-        $object->email=$email;
-        $object->pass=$email;
+        $object = new stdClass();
+        $object->email = $email;
+        $object->pass = $email;
         /*$object->element='member';
         $object->type='Preferred Partners'; */
 
         if ($action == 'testsubscribe')
         {
-            $result=$mailmanspip->add_to_mailman($object);
+            $result = $mailmanspip->add_to_mailman($object);
 			if ($result < 0)
 			{
 				$error++;
@@ -126,7 +126,7 @@ if (($action == 'testsubscribe' || $action == 'testunsubscribe') && ! empty($con
         }
         if ($action == 'testunsubscribe')
         {
-            $result=$mailmanspip->del_to_mailman($object);
+            $result = $mailmanspip->del_to_mailman($object);
             if ($result < 0)
 			{
 				$error++;
@@ -145,17 +145,17 @@ if (($action == 'testsubscribe' || $action == 'testunsubscribe') && ! empty($con
  * View
  */
 
-$help_url='';
+$help_url = '';
 
 llxHeader('', $langs->trans("MailmanSpipSetup"), $help_url);
 
 
-$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("MailmanSpipSetup"), $linkback, 'title_setup');
 
 $head = mailmanspip_admin_prepare_head();
 
-if (! empty($conf->global->ADHERENT_USE_MAILMAN))
+if (!empty($conf->global->ADHERENT_USE_MAILMAN))
 {
     print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
     print '<input type="hidden" name="token" value="'.newToken().'">';
@@ -164,12 +164,12 @@ if (! empty($conf->global->ADHERENT_USE_MAILMAN))
     dol_fiche_head($head, 'mailman', $langs->trans("Setup"), -1, 'user');
 
     //$link=img_picto($langs->trans("Active"),'tick').' ';
-    $link='<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=unset&value=0&name=ADHERENT_USE_MAILMAN">';
+    $link = '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=unset&value=0&name=ADHERENT_USE_MAILMAN">';
     //$link.=$langs->trans("Disable");
-    $link.=img_picto($langs->trans("Activated"), 'switch_on');
-    $link.='</a>';
+    $link .= img_picto($langs->trans("Activated"), 'switch_on');
+    $link .= '</a>';
     // Edition des varibales globales
-    $constantes=array(
+    $constantes = array(
         'ADHERENT_MAILMAN_ADMINPW',
         'ADHERENT_MAILMAN_URL',
         'ADHERENT_MAILMAN_UNSUB_URL',
@@ -216,17 +216,17 @@ else
 {
     dol_fiche_head($head, 'mailman', $langs->trans("Setup"), 0, 'user');
 
-    $link='<a href="'.$_SERVER["PHP_SELF"].'?action=set&value=1&name=ADHERENT_USE_MAILMAN">';
+    $link = '<a href="'.$_SERVER["PHP_SELF"].'?action=set&value=1&name=ADHERENT_USE_MAILMAN">';
     //$link.=img_$langs->trans("Activate")
-    $link.=img_picto($langs->trans("Disabled"), 'switch_off');
-    $link.='</a>';
+    $link .= img_picto($langs->trans("Disabled"), 'switch_off');
+    $link .= '</a>';
     print load_fiche_titre($langs->trans('MailmanTitle'), $link, '');
 
     dol_fiche_end();
 }
 
 
-if (! empty($conf->global->ADHERENT_USE_MAILMAN))
+if (!empty($conf->global->ADHERENT_USE_MAILMAN))
 {
     print '<form action="'.$_SERVER["PHP_SELF"].'">';
     print '<input type="hidden" name="token" value="'.newToken().'">';

+ 2 - 2
htdocs/admin/mails.php

@@ -99,7 +99,7 @@ $triggersendname = ''; // Disable triggers
 $paramname = 'id';
 $mode = 'emailfortest';
 $trackid = (($action == 'testhtml') ? "testhtml" : "test");
-$sendcontext='';
+$sendcontext = '';
 include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
 
 if ($action == 'presend' && GETPOST('trackid', 'alphanohtml') == 'test')       $action = 'test';
@@ -758,7 +758,7 @@ else
 		$text = '';
 		if ($conf->global->MAIN_MAIL_SENDMODE == 'mail')
 		{
-			$text .= $langs->trans("WarningPHPMail");	// To encourage to use SMTPS
+			$text .= $langs->trans("WarningPHPMail"); // To encourage to use SMTPS
 		}
 
 		if ($conf->global->MAIN_MAIL_SENDMODE == 'mail')

+ 88 - 88
htdocs/admin/mails_emailing.php

@@ -30,24 +30,24 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
 // Load translation files required by the page
 $langs->loadLangs(array('companies', 'products', 'admin', 'mails', 'other', 'errors'));
 
-$action=GETPOST('action', 'alpha');
+$action = GETPOST('action', 'alpha');
 
-if (! $user->admin) accessforbidden();
+if (!$user->admin) accessforbidden();
 
-$usersignature=$user->signature;
+$usersignature = $user->signature;
 // For action = test or send, we ensure that content is not html, even for signature, because this we want a test with NO html.
 if ($action == 'test' || $action == 'send')
 {
-	$usersignature=dol_string_nohtmltag($usersignature);
+	$usersignature = dol_string_nohtmltag($usersignature);
 }
 
-$substitutionarrayfortest=array(
+$substitutionarrayfortest = array(
 '__LOGIN__' => $user->login,
 '__ID__' => 'TESTIdRecord',
 '__EMAIL__' => 'TESTEMail',
 '__LASTNAME__' => 'TESTLastname',
 '__FIRSTNAME__' => 'TESTFirstname',
-'__USER_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$usersignature:''),
+'__USER_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $usersignature : ''),
 //'__PERSONALIZED__' => 'TESTPersonalized'	// Hiden because not used yet
 );
 complete_substitutions_array($substitutionarrayfortest, $langs);
@@ -75,17 +75,17 @@ if ($action == 'update' && empty($_POST["cancel"]))
 
 
 // Actions to send emails
-$id=0;
-$actiontypecode='';     // Not an event for agenda
-$triggersendname = '';       // Disable triggers
-$paramname='id';
-$mode='emailfortest';
-$trackid=(($action == 'testhtml')?"testhtml":"test");
-$sendcontext='emailing';	// Force to use dedicated context of setup for emailing
+$id = 0;
+$actiontypecode = ''; // Not an event for agenda
+$triggersendname = ''; // Disable triggers
+$paramname = 'id';
+$mode = 'emailfortest';
+$trackid = (($action == 'testhtml') ? "testhtml" : "test");
+$sendcontext = 'emailing'; // Force to use dedicated context of setup for emailing
 include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
 
-if ($action == 'presend' && GETPOST('trackid') == 'test')       $action='test';
-if ($action == 'presend' && GETPOST('trackid') == 'testhtml')   $action='testhtml';
+if ($action == 'presend' && GETPOST('trackid') == 'test')       $action = 'test';
+if ($action == 'presend' && GETPOST('trackid') == 'testhtml')   $action = 'testhtml';
 
 
 
@@ -96,18 +96,18 @@ if ($action == 'presend' && GETPOST('trackid') == 'testhtml')   $action='testhtm
 
 $form = new Form($db);
 
-$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;
 
-if (empty($conf->global->MAIN_MAIL_SENDMODE_EMAILING)) $conf->global->MAIN_MAIL_SENDMODE_EMAILING='default';
-$port=! empty($conf->global->MAIN_MAIL_SMTP_PORT_EMAILING)?$conf->global->MAIN_MAIL_SMTP_PORT_EMAILING:ini_get('smtp_port');
-if (! $port) $port=25;
-$server=! empty($conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING)?$conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING:ini_get('SMTP');
-if (! $server) $server='127.0.0.1';
+if (empty($conf->global->MAIN_MAIL_SENDMODE_EMAILING)) $conf->global->MAIN_MAIL_SENDMODE_EMAILING = 'default';
+$port = !empty($conf->global->MAIN_MAIL_SMTP_PORT_EMAILING) ? $conf->global->MAIN_MAIL_SMTP_PORT_EMAILING : ini_get('smtp_port');
+if (!$port) $port = 25;
+$server = !empty($conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING) ? $conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING : ini_get('SMTP');
+if (!$server) $server = '127.0.0.1';
 
 
-$wikihelp='EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails';
+$wikihelp = 'EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails';
 llxHeader('', $langs->trans("Setup"), $wikihelp);
 
 print load_fiche_titre($langs->trans("EMailsSetup"), '', 'title_setup');
@@ -115,12 +115,12 @@ print load_fiche_titre($langs->trans("EMailsSetup"), '', 'title_setup');
 $head = email_admin_prepare_head();
 
 // List of sending methods
-$listofmethods=array();
-$listofmethods['default']=$langs->trans('DefaultOutgoingEmailSetup');
-$listofmethods['mail']='PHP mail function';
+$listofmethods = array();
+$listofmethods['default'] = $langs->trans('DefaultOutgoingEmailSetup');
+$listofmethods['mail'] = 'PHP mail function';
 //$listofmethods['simplemail']='Simplemail class';
-$listofmethods['smtps']='SMTP/SMTPS socket library';
-$listofmethods['swiftmailer']='Swift Mailer socket library';
+$listofmethods['smtps'] = 'SMTP/SMTPS socket library';
+$listofmethods['swiftmailer'] = 'Swift Mailer socket library';
 
 
 if ($action == 'edit')
@@ -250,7 +250,7 @@ if ($action == 'edit')
 	// Host server
 
 	print '<tr class="oddeven hideifdefault"><td>';
-	if (! $conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE_EMAILING == 'mail')
+	if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE_EMAILING == 'mail')
 	{
 		print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
 		print '</td><td>';
@@ -258,21 +258,21 @@ if ($action == 'edit')
 	}
 	else
 	{
-		$mainserver = (! empty($conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING)?$conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING:'');
-		$smtpserver = ini_get('SMTP')?ini_get('SMTP'):$langs->transnoentities("Undefined");
+		$mainserver = (!empty($conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING) ? $conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING : '');
+		$smtpserver = ini_get('SMTP') ?ini_get('SMTP') : $langs->transnoentities("Undefined");
 		if ($linuxlike) print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
 		else print $langs->trans("MAIN_MAIL_SMTP_SERVER", $smtpserver);
 		print '</td><td>';
 		// SuperAdministrator access only
-		if (empty($conf->multicompany->enabled) || ($user->admin && ! $user->entity))
+		if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity))
 		{
-			print '<input class="flat" id="MAIN_MAIL_SMTP_SERVER_EMAILING" name="MAIN_MAIL_SMTP_SERVER_EMAILING" size="18" value="' . $mainserver . '">';
-			print '<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_EMAILING_sav" name="MAIN_MAIL_SMTP_SERVER_EMAILING_sav" value="' . $mainserver . '">';
+			print '<input class="flat" id="MAIN_MAIL_SMTP_SERVER_EMAILING" name="MAIN_MAIL_SMTP_SERVER_EMAILING" size="18" value="'.$mainserver.'">';
+			print '<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_EMAILING_sav" name="MAIN_MAIL_SMTP_SERVER_EMAILING_sav" value="'.$mainserver.'">';
 			print '<span id="smtp_server_mess">'.$langs->trans("SeeLocalSendMailSetup").'</span>';
 		}
 		else
 		{
-			$text = ! empty($mainserver) ? $mainserver : $smtpserver;
+			$text = !empty($mainserver) ? $mainserver : $smtpserver;
 			$htmltext = $langs->trans("ContactSuperAdminForChange");
 			print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
 			print '<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_EMAILING" name="MAIN_MAIL_SMTP_SERVER_EMAILING" value="'.$mainserver.'">';
@@ -283,7 +283,7 @@ if ($action == 'edit')
 	// Port
 
 	print '<tr class="oddeven hideifdefault"><td>';
-	if (! $conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE_EMAILING == 'mail')
+	if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE_EMAILING == 'mail')
 	{
 		print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
 		print '</td><td>';
@@ -291,21 +291,21 @@ if ($action == 'edit')
 	}
 	else
 	{
-		$mainport = (! empty($conf->global->MAIN_MAIL_SMTP_PORT_EMAILING) ? $conf->global->MAIN_MAIL_SMTP_PORT_EMAILING : '');
-		$smtpport = ini_get('smtp_port')?ini_get('smtp_port'):$langs->transnoentities("Undefined");
+		$mainport = (!empty($conf->global->MAIN_MAIL_SMTP_PORT_EMAILING) ? $conf->global->MAIN_MAIL_SMTP_PORT_EMAILING : '');
+		$smtpport = ini_get('smtp_port') ?ini_get('smtp_port') : $langs->transnoentities("Undefined");
 		if ($linuxlike) print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
 		else print $langs->trans("MAIN_MAIL_SMTP_PORT", $smtpport);
 		print '</td><td>';
 		// SuperAdministrator access only
-		if (empty($conf->multicompany->enabled) || ($user->admin && ! $user->entity))
+		if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity))
 		{
-			print '<input class="flat" id="MAIN_MAIL_SMTP_PORT_EMAILING" name="MAIN_MAIL_SMTP_PORT_EMAILING" size="3" value="' . $mainport . '">';
-			print '<input type="hidden" id="MAIN_MAIL_SMTP_PORT_EMAILING_sav" name="MAIN_MAIL_SMTP_PORT_EMAILING_sav" value="' . $mainport . '">';
+			print '<input class="flat" id="MAIN_MAIL_SMTP_PORT_EMAILING" name="MAIN_MAIL_SMTP_PORT_EMAILING" size="3" value="'.$mainport.'">';
+			print '<input type="hidden" id="MAIN_MAIL_SMTP_PORT_EMAILING_sav" name="MAIN_MAIL_SMTP_PORT_EMAILING_sav" value="'.$mainport.'">';
 			print '<span id="smtp_port_mess">'.$langs->trans("SeeLocalSendMailSetup").'</span>';
 		}
 		else
 		{
-			$text = (! empty($mainport) ? $mainport : $smtpport);
+			$text = (!empty($mainport) ? $mainport : $smtpport);
 			$htmltext = $langs->trans("ContactSuperAdminForChange");
 			print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
 			print '<input type="hidden" id="MAIN_MAIL_SMTP_PORT_EMAILING" name="MAIN_MAIL_SMTP_PORT_EMAILING" value="'.$mainport.'">';
@@ -314,14 +314,14 @@ if ($action == 'edit')
 	print '</td></tr>';
 
 	// ID
-	if (! empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer'))))
+	if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer'))))
 	{
-		$mainstmpid=(! empty($conf->global->MAIN_MAIL_SMTPS_ID_EMAILING)?$conf->global->MAIN_MAIL_SMTPS_ID_EMAILING:'');
+		$mainstmpid = (!empty($conf->global->MAIN_MAIL_SMTPS_ID_EMAILING) ? $conf->global->MAIN_MAIL_SMTPS_ID_EMAILING : '');
 		print '<tr class="drag drop oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_ID").'</td><td>';
 		// SuperAdministrator access only
 		if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity))
 		{
-			print '<input class="flat" name="MAIN_MAIL_SMTPS_ID_EMAILING" size="32" value="' . $mainstmpid . '">';
+			print '<input class="flat" name="MAIN_MAIL_SMTPS_ID_EMAILING" size="32" value="'.$mainstmpid.'">';
 		}
 		else
 		{
@@ -333,14 +333,14 @@ if ($action == 'edit')
 	}
 
 	// PW
-	if (! empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer'))))
+	if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer'))))
 	{
-		$mainsmtppw=(! empty($conf->global->MAIN_MAIL_SMTPS_PW_EMAILING)?$conf->global->MAIN_MAIL_SMTPS_PW_EMAILING:'');
+		$mainsmtppw = (!empty($conf->global->MAIN_MAIL_SMTPS_PW_EMAILING) ? $conf->global->MAIN_MAIL_SMTPS_PW_EMAILING : '');
 		print '<tr class="drag drop oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_PW").'</td><td>';
 		// SuperAdministrator access only
 		if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity))
 		{
-			print '<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW_EMAILING" size="32" value="' . $mainsmtppw . '">';
+			print '<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW_EMAILING" size="32" value="'.$mainsmtppw.'">';
 		}
 		else
 		{
@@ -354,11 +354,11 @@ if ($action == 'edit')
 	// TLS
 
 	print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_TLS").'</td><td>';
-	if (! empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer'))))
+	if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer'))))
 	{
 		if (function_exists('openssl_open'))
 		{
-			print $form->selectyesno('MAIN_MAIL_EMAIL_TLS_EMAILING', (! empty($conf->global->MAIN_MAIL_EMAIL_TLS_EMAILING)?$conf->global->MAIN_MAIL_EMAIL_TLS_EMAILING:0), 1);
+			print $form->selectyesno('MAIN_MAIL_EMAIL_TLS_EMAILING', (!empty($conf->global->MAIN_MAIL_EMAIL_TLS_EMAILING) ? $conf->global->MAIN_MAIL_EMAIL_TLS_EMAILING : 0), 1);
 		}
 		else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
 	}
@@ -368,11 +368,11 @@ if ($action == 'edit')
 	// STARTTLS
 
 	print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").'</td><td>';
-	if (! empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer'))))
+	if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer'))))
 	{
 		if (function_exists('openssl_open'))
 		{
-			print $form->selectyesno('MAIN_MAIL_EMAIL_STARTTLS_EMAILING', (! empty($conf->global->MAIN_MAIL_EMAIL_STARTTLS_EMAILING)?$conf->global->MAIN_MAIL_EMAIL_STARTTLS_EMAILING:0), 1);
+			print $form->selectyesno('MAIN_MAIL_EMAIL_STARTTLS_EMAILING', (!empty($conf->global->MAIN_MAIL_EMAIL_STARTTLS_EMAILING) ? $conf->global->MAIN_MAIL_EMAIL_STARTTLS_EMAILING : 0), 1);
 		}
 		else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
 	}
@@ -403,12 +403,12 @@ else
 
 	// Method
 	print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SENDMODE").'</td><td>';
-	$text=$listofmethods[$conf->global->MAIN_MAIL_SENDMODE_EMAILING];
-	if (empty($text)) $text=$langs->trans("Undefined").img_warning();
+	$text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE_EMAILING];
+	if (empty($text)) $text = $langs->trans("Undefined").img_warning();
 	print $text;
 	print '</td></tr>';
 
-	if (! empty($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING != 'default')
+	if (!empty($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING != 'default')
 	{
 		// Host server
 		if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING == 'mail'))
@@ -417,7 +417,7 @@ else
 		}
 		else
 		{
-			print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTP_SERVER", ini_get('SMTP')?ini_get('SMTP'):$langs->transnoentities("Undefined")).'</td><td>'.(! empty($conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING)?$conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING:'').'</td></tr>';
+			print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTP_SERVER", ini_get('SMTP') ?ini_get('SMTP') : $langs->transnoentities("Undefined")).'</td><td>'.(!empty($conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING) ? $conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING : '').'</td></tr>';
 		}
 
 		// Port
@@ -427,7 +427,7 @@ else
 		}
 		else
 		{
-			print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTP_PORT", ini_get('smtp_port')?ini_get('smtp_port'):$langs->transnoentities("Undefined")).'</td><td>'.(! empty($conf->global->MAIN_MAIL_SMTP_PORT_EMAILING)?$conf->global->MAIN_MAIL_SMTP_PORT_EMAILING:'').'</td></tr>';
+			print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTP_PORT", ini_get('smtp_port') ?ini_get('smtp_port') : $langs->transnoentities("Undefined")).'</td><td>'.(!empty($conf->global->MAIN_MAIL_SMTP_PORT_EMAILING) ? $conf->global->MAIN_MAIL_SMTP_PORT_EMAILING : '').'</td></tr>';
 		}
 
 		// SMTPS ID
@@ -498,9 +498,9 @@ else
 
 	print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>';
 
-	if (! empty($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING != 'default')
+	if (!empty($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING != 'default')
 	{
-		if ($conf->global->MAIN_MAIL_SENDMODE_EMAILING != 'mail' || ! $linuxlike)
+		if ($conf->global->MAIN_MAIL_SENDMODE_EMAILING != 'mail' || !$linuxlike)
 		{
 			if (function_exists('fsockopen') && $port && $server)
 			{
@@ -514,7 +514,7 @@ else
 
 		print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=test&amp;mode=init">'.$langs->trans("DoTestSend").'</a>';
 
-		if (! empty($conf->fckeditor->enabled))
+		if (!empty($conf->fckeditor->enabled))
 		{
 			print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=testhtml&amp;mode=init">'.$langs->trans("DoTestSendHTML").'</a>';
 		}
@@ -523,7 +523,7 @@ else
 	print '</div>';
 
 
-	if ($conf->global->MAIN_MAIL_SENDMODE_EMAILING == 'mail' && ! in_array($action, array('testconnect', 'test', 'testhtml')))
+	if ($conf->global->MAIN_MAIL_SENDMODE_EMAILING == 'mail' && !in_array($action, array('testconnect', 'test', 'testhtml')))
 	{
         $text = $langs->trans("WarningPHPMail");
 	    print info_admin($text);
@@ -556,42 +556,42 @@ else
 	if ($action == 'test' || $action == 'testhtml')
 	{
 	    print '<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
-		print load_fiche_titre($action == 'testhtml'?$langs->trans("DoTestSendHTML"):$langs->trans("DoTestSend"));
+		print load_fiche_titre($action == 'testhtml' ? $langs->trans("DoTestSendHTML") : $langs->trans("DoTestSend"));
 
 		dol_fiche_head('');
 
 		// Cree l'objet formulaire mail
 		include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
 		$formmail = new FormMail($db);
-		$formmail->fromname = (isset($_POST['fromname'])?$_POST['fromname']:$conf->global->MAIN_MAIL_EMAIL_FROM);
-		$formmail->frommail = (isset($_POST['frommail'])?$_POST['frommail']:$conf->global->MAIN_MAIL_EMAIL_FROM);
-		$formmail->trackid=(($action == 'testhtml')?"testhtml":"test");
-		$formmail->withfromreadonly=0;
-		$formmail->withsubstit=0;
-		$formmail->withfrom=1;
-		$formmail->witherrorsto=1;
-		$formmail->withto=(! empty($_POST['sendto'])?$_POST['sendto']:($user->email?$user->email:1));
-		$formmail->withtocc=(! empty($_POST['sendtocc'])?$_POST['sendtocc']:1);       // ! empty to keep field if empty
-		$formmail->withtoccc=(! empty($_POST['sendtoccc'])?$_POST['sendtoccc']:1);    // ! empty to keep field if empty
-		$formmail->withtopic=(isset($_POST['subject'])?$_POST['subject']:$langs->trans("Test"));
-		$formmail->withtopicreadonly=0;
-		$formmail->withfile=2;
-		$formmail->withbody=(isset($_POST['message'])?$_POST['message']:($action == 'testhtml'?$langs->transnoentities("PredefinedMailTestHtml"):$langs->transnoentities("PredefinedMailTest")));
-		$formmail->withbodyreadonly=0;
-		$formmail->withcancel=1;
-		$formmail->withdeliveryreceipt=1;
-		$formmail->withfckeditor=($action == 'testhtml'?1:0);
-		$formmail->ckeditortoolbar='dolibarr_mailings';
+		$formmail->fromname = (isset($_POST['fromname']) ? $_POST['fromname'] : $conf->global->MAIN_MAIL_EMAIL_FROM);
+		$formmail->frommail = (isset($_POST['frommail']) ? $_POST['frommail'] : $conf->global->MAIN_MAIL_EMAIL_FROM);
+		$formmail->trackid = (($action == 'testhtml') ? "testhtml" : "test");
+		$formmail->withfromreadonly = 0;
+		$formmail->withsubstit = 0;
+		$formmail->withfrom = 1;
+		$formmail->witherrorsto = 1;
+		$formmail->withto = (!empty($_POST['sendto']) ? $_POST['sendto'] : ($user->email ? $user->email : 1));
+		$formmail->withtocc = (!empty($_POST['sendtocc']) ? $_POST['sendtocc'] : 1); // ! empty to keep field if empty
+		$formmail->withtoccc = (!empty($_POST['sendtoccc']) ? $_POST['sendtoccc'] : 1); // ! empty to keep field if empty
+		$formmail->withtopic = (isset($_POST['subject']) ? $_POST['subject'] : $langs->trans("Test"));
+		$formmail->withtopicreadonly = 0;
+		$formmail->withfile = 2;
+		$formmail->withbody = (isset($_POST['message']) ? $_POST['message'] : ($action == 'testhtml' ? $langs->transnoentities("PredefinedMailTestHtml") : $langs->transnoentities("PredefinedMailTest")));
+		$formmail->withbodyreadonly = 0;
+		$formmail->withcancel = 1;
+		$formmail->withdeliveryreceipt = 1;
+		$formmail->withfckeditor = ($action == 'testhtml' ? 1 : 0);
+		$formmail->ckeditortoolbar = 'dolibarr_mailings';
 		// Tableau des substitutions
-		$formmail->substit=$substitutionarrayfortest;
+		$formmail->substit = $substitutionarrayfortest;
 		// Tableau des parametres complementaires du post
-		$formmail->param["action"]="send";
-		$formmail->param["models"]="body";
-		$formmail->param["mailid"]=0;
-		$formmail->param["returnurl"]=$_SERVER["PHP_SELF"];
+		$formmail->param["action"] = "send";
+		$formmail->param["models"] = "body";
+		$formmail->param["mailid"] = 0;
+		$formmail->param["returnurl"] = $_SERVER["PHP_SELF"];
 
 		// Init list of files
-        if (GETPOST("mode")=='init')
+        if (GETPOST("mode") == 'init')
 		{
 			$formmail->clear_attached_files();
 		}

+ 36 - 36
htdocs/admin/menus.php

@@ -27,32 +27,32 @@ require '../main.inc.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
 
-$action=GETPOST('action', 'aZ09');
-$cancel=GETPOST('cancel', 'alpha');
+$action = GETPOST('action', 'aZ09');
+$cancel = GETPOST('cancel', 'alpha');
 
 // Load translation files required by the page
-$langs->loadLangs(array("companies","products","admin","users","other"));
+$langs->loadLangs(array("companies", "products", "admin", "users", "other"));
 
 // Security check
-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';
 }
 
-$error=0;
+$error = 0;
 
 // Cette page peut etre longue. On augmente le delai autorise.
 // Ne fonctionne que si on est pas en safe_mode.
-$err=error_reporting();
-error_reporting(0);     // Disable all errors
+$err = error_reporting();
+error_reporting(0); // Disable all errors
 //error_reporting(E_ALL);
-@set_time_limit(300);   // Need more than 240 on Windows 7/64
+@set_time_limit(300); // Need more than 240 on Windows 7/64
 error_reporting($err);
 
 
@@ -60,9 +60,9 @@ error_reporting($err);
  * Actions
  */
 
-if ($action == 'update' && ! $cancel)
+if ($action == 'update' && !$cancel)
 {
-	$_SESSION["mainmenu"]="home";   // Le gestionnaire de menu a pu changer
+	$_SESSION["mainmenu"] = "home"; // Le gestionnaire de menu a pu changer
 
 	dolibarr_set_const($db, "MAIN_MENU_STANDARD", GETPOST('MAIN_MENU_STANDARD', 'alpha'), 'chaine', 0, '', $conf->entity);
 	dolibarr_set_const($db, "MAIN_MENU_SMARTPHONE", GETPOST('MAIN_MENU_SMARTPHONE', 'alpha'), 'chaine', 0, '', $conf->entity);
@@ -71,28 +71,28 @@ if ($action == 'update' && ! $cancel)
 	dolibarr_set_const($db, "MAIN_MENUFRONT_SMARTPHONE", GETPOST('MAIN_MENUFRONT_SMARTPHONE', 'alpha'), 'chaine', 0, '', $conf->entity);
 
 	// Define list of menu handlers to initialize
-	$listofmenuhandler=array();
-	$listofmenuhandler[preg_replace('/(_backoffice|_frontoffice|_menu)?\.php/i', '', GETPOST('MAIN_MENU_STANDARD', 'alpha'))]=1;
-	$listofmenuhandler[preg_replace('/(_backoffice|_frontoffice|_menu)?\.php/i', '', GETPOST('MAIN_MENUFRONT_STANDARD', 'alpha'))]=1;
-	if (GETPOST('MAIN_MENU_SMARTPHONE', 'alpha'))      $listofmenuhandler[preg_replace('/(_backoffice|_frontoffice|_menu)?\.php/i', '', GETPOST('MAIN_MENU_SMARTPHONE', 'alpha'))]=1;
-	if (GETPOST('MAIN_MENUFRONT_SMARTPHONE', 'alpha')) $listofmenuhandler[preg_replace('/(_backoffice|_frontoffice|_menu)?\.php/i', '', GETPOST('MAIN_MENUFRONT_SMARTPHONE', 'alpha'))]=1;
+	$listofmenuhandler = array();
+	$listofmenuhandler[preg_replace('/(_backoffice|_frontoffice|_menu)?\.php/i', '', GETPOST('MAIN_MENU_STANDARD', 'alpha'))] = 1;
+	$listofmenuhandler[preg_replace('/(_backoffice|_frontoffice|_menu)?\.php/i', '', GETPOST('MAIN_MENUFRONT_STANDARD', 'alpha'))] = 1;
+	if (GETPOST('MAIN_MENU_SMARTPHONE', 'alpha'))      $listofmenuhandler[preg_replace('/(_backoffice|_frontoffice|_menu)?\.php/i', '', GETPOST('MAIN_MENU_SMARTPHONE', 'alpha'))] = 1;
+	if (GETPOST('MAIN_MENUFRONT_SMARTPHONE', 'alpha')) $listofmenuhandler[preg_replace('/(_backoffice|_frontoffice|_menu)?\.php/i', '', GETPOST('MAIN_MENUFRONT_SMARTPHONE', 'alpha'))] = 1;
 
 	// Initialize menu handlers
 	foreach ($listofmenuhandler as $key => $val)
 	{
 		// Load sql init_menu_handler.sql file
-		$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)
 		{
-			$file='init_menu_'.$key.'.sql';
-			$fullpath=dol_buildpath($dirmenu.$file);
+			$file = 'init_menu_'.$key.'.sql';
+			$fullpath = dol_buildpath($dirmenu.$file);
 			//print 'action='.$action.' Search menu into fullpath='.$fullpath.'<br>';exit;
 
 			if (file_exists($fullpath))
 			{
 				$db->begin();
 
-				$result=run_sql($fullpath, 1, '', 1, $key, 'none');
+				$result = run_sql($fullpath, 1, '', 1, $key, 'none');
 				if ($result > 0)
 				{
 					$db->commit();
@@ -107,7 +107,7 @@ if ($action == 'update' && ! $cancel)
 		}
 	}
 
-	if (! $error)
+	if (!$error)
 	{
 		$db->close();
 
@@ -122,10 +122,10 @@ if ($action == 'update' && ! $cancel)
  * View
  */
 
-$form=new Form($db);
-$formadmin=new FormAdmin($db);
+$form = new Form($db);
+$formadmin = new FormAdmin($db);
 
-$wikihelp='EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones';
+$wikihelp = 'EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones';
 llxHeader('', $langs->trans("Setup"), $wikihelp);
 
 print load_fiche_titre($langs->trans("Menus"), '', 'title_setup');
@@ -175,30 +175,30 @@ print '</tr>';
 // Menu top
 print '<tr class="oddeven"><td>'.$langs->trans("DefaultMenuManager").'</td>';
 print '<td>';
-$formadmin->select_menu(empty($conf->global->MAIN_MENU_STANDARD_FORCED)?$conf->global->MAIN_MENU_STANDARD:$conf->global->MAIN_MENU_STANDARD_FORCED, 'MAIN_MENU_STANDARD', $dirstandard, empty($conf->global->MAIN_MENU_STANDARD_FORCED)?'':' disabled');
+$formadmin->select_menu(empty($conf->global->MAIN_MENU_STANDARD_FORCED) ? $conf->global->MAIN_MENU_STANDARD : $conf->global->MAIN_MENU_STANDARD_FORCED, 'MAIN_MENU_STANDARD', $dirstandard, empty($conf->global->MAIN_MENU_STANDARD_FORCED) ? '' : ' disabled');
 print '</td>';
 print '<td>';
-$formadmin->select_menu(empty($conf->global->MAIN_MENUFRONT_STANDARD_FORCED)?$conf->global->MAIN_MENUFRONT_STANDARD:$conf->global->MAIN_MENUFRONT_STANDARD_FORCED, 'MAIN_MENUFRONT_STANDARD', $dirstandard, empty($conf->global->MAIN_MENUFRONT_STANDARD_FORCED)?'':' disabled');
+$formadmin->select_menu(empty($conf->global->MAIN_MENUFRONT_STANDARD_FORCED) ? $conf->global->MAIN_MENUFRONT_STANDARD : $conf->global->MAIN_MENUFRONT_STANDARD_FORCED, 'MAIN_MENUFRONT_STANDARD', $dirstandard, empty($conf->global->MAIN_MENUFRONT_STANDARD_FORCED) ? '' : ' disabled');
 print '</td>';
 print '</tr>';
 
 // Menu smartphone
 print '<tr class="oddeven"><td>'.$langs->trans("DefaultMenuSmartphoneManager").'</td>';
 print '<td>';
-$formadmin->select_menu(empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED)?$conf->global->MAIN_MENU_SMARTPHONE:$conf->global->MAIN_MENU_SMARTPHONE_FORCED, 'MAIN_MENU_SMARTPHONE', array_merge($dirstandard, $dirsmartphone), empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED)?'':' disabled');
+$formadmin->select_menu(empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED) ? $conf->global->MAIN_MENU_SMARTPHONE : $conf->global->MAIN_MENU_SMARTPHONE_FORCED, 'MAIN_MENU_SMARTPHONE', array_merge($dirstandard, $dirsmartphone), empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED) ? '' : ' disabled');
 
-if (! empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED) && preg_match('/smartphone/', $conf->global->MAIN_MENU_SMARTPHONE_FORCED)
-	|| (empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED) && ! empty($conf->global->MAIN_MENU_SMARTPHONE) && preg_match('/smartphone/', $conf->global->MAIN_MENU_SMARTPHONE)))
+if (!empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED) && preg_match('/smartphone/', $conf->global->MAIN_MENU_SMARTPHONE_FORCED)
+	|| (empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED) && !empty($conf->global->MAIN_MENU_SMARTPHONE) && preg_match('/smartphone/', $conf->global->MAIN_MENU_SMARTPHONE)))
 {
 	print ' '.img_warning($langs->transnoentitiesnoconv("ThisForceAlsoTheme"));
 }
 
 print '</td>';
 print '<td>';
-$formadmin->select_menu(empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED)?$conf->global->MAIN_MENUFRONT_SMARTPHONE:$conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED, 'MAIN_MENUFRONT_SMARTPHONE', array_merge($dirstandard, $dirsmartphone), empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED)?'':' disabled');
+$formadmin->select_menu(empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED) ? $conf->global->MAIN_MENUFRONT_SMARTPHONE : $conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED, 'MAIN_MENUFRONT_SMARTPHONE', array_merge($dirstandard, $dirsmartphone), empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED) ? '' : ' disabled');
 
-if (! empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED) && preg_match('/smartphone/', $conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED)
-	|| (empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED) && ! empty($conf->global->MAIN_MENU_SMARTPHONE) && preg_match('/smartphone/', $conf->global->MAIN_MENUFRONT_SMARTPHONE)))
+if (!empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED) && preg_match('/smartphone/', $conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED)
+	|| (empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED) && !empty($conf->global->MAIN_MENU_SMARTPHONE) && preg_match('/smartphone/', $conf->global->MAIN_MENUFRONT_SMARTPHONE)))
 {
 	print ' '.img_warning($langs->transnoentitiesnoconv("ThisForceAlsoTheme"));
 }

+ 5 - 5
htdocs/admin/menus/index.php

@@ -245,24 +245,24 @@ print "<br>\n";
 if ($action == 'delete')
 {
 	$sql = "SELECT m.titre as title";
-	$sql.= " FROM ".MAIN_DB_PREFIX."menu as m";
-	$sql.= " WHERE m.rowid = ".GETPOST('menuId', 'int');
+	$sql .= " FROM ".MAIN_DB_PREFIX."menu as m";
+	$sql .= " WHERE m.rowid = ".GETPOST('menuId', 'int');
 	$result = $db->query($sql);
 	$obj = $db->fetch_object($result);
 
     print $form->formconfirm("index.php?menu_handler=".$menu_handler."&menuId=".GETPOST('menuId', 'int'), $langs->trans("DeleteMenu"), $langs->trans("ConfirmDeleteMenu", $obj->title), "confirm_delete");
 }
 
-$newcardbutton='';
+$newcardbutton = '';
 if ($user->admin)
 {
-    $newcardbutton.= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/admin/menus/edit.php?menuId=0&action=create&menu_handler='.urlencode($menu_handler).'&backtopage='.urlencode($_SERVER['PHP_SELF']));
+    $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/admin/menus/edit.php?menuId=0&action=create&menu_handler='.urlencode($menu_handler).'&backtopage='.urlencode($_SERVER['PHP_SELF']));
 }
 
 print '<form name="newmenu" class="nocellnopadd" action="'.$_SERVER["PHP_SELF"].'">';
 print '<input type="hidden" action="change_menu_handler">';
 print $langs->trans("MenuHandler").': ';
-$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 ' &nbsp; <input type="submit" class="button" value="'.$langs->trans("Refresh").'">';
 
 print '<div class="floatright">';

+ 3 - 3
htdocs/admin/menus/other.php

@@ -25,11 +25,11 @@ require '../../main.inc.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
 
 // Load translation files required by the page
-$langs->loadLangs(array("user","other","admin"));
+$langs->loadLangs(array("user", "other", "admin"));
 
-if (! $user->admin) accessforbidden();
+if (!$user->admin) accessforbidden();
 
-$action=GETPOST('action', 'alpha');
+$action = GETPOST('action', 'alpha');
 
 
 /*

+ 175 - 175
htdocs/admin/modulehelp.php

@@ -21,8 +21,8 @@
  *  \brief      Page to activate/disable all modules
  */
 
-if (! defined('NOREQUIREMENU'))  define('NOREQUIREMENU', '1');	// If there is no need to load and show top and left menu
-if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1');	// Disabled because this page is into a popup on module search page and we want to avoid to have an Anti CSRF token error (done if MAIN_SECURITY_CSRF_WITH_TOKEN is on) when we make a second search after closing popup.
+if (!defined('NOREQUIREMENU'))  define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu
+if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disabled because this page is into a popup on module search page and we want to avoid to have an Anti CSRF token error (done if MAIN_SECURITY_CSRF_WITH_TOKEN is on) when we make a second search after closing popup.
 
 
 require '../main.inc.php';
@@ -33,12 +33,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
 // Load translation files required by the page
 $langs->loadLangs(array('errors', 'admin'));
 
-$mode=GETPOST('mode', 'alpha');
-$action=GETPOST('action', 'alpha');
+$mode = GETPOST('mode', 'alpha');
+$action = GETPOST('action', 'alpha');
 $id = GETPOST('id', 'int');
-if (empty($mode)) $mode='desc';
+if (empty($mode)) $mode = 'desc';
 
-if (! $user->admin)
+if (!$user->admin)
 	accessforbidden();
 
 
@@ -56,7 +56,7 @@ if (! $user->admin)
 
 $form = new Form($db);
 
-$help_url='EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones';
+$help_url = 'EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones';
 llxHeader('', $langs->trans("Setup"), $help_url);
 
 print '<!-- Force style container -->'."\n".'<style>
@@ -65,7 +65,7 @@ print '<!-- Force style container -->'."\n".'<style>
 }
 </style>';
 
-$arrayofnatures=array('core'=>$langs->transnoentitiesnoconv("Core"), 'external'=>$langs->transnoentitiesnoconv("External").' - '.$langs->trans("AllPublishers"));
+$arrayofnatures = array('core'=>$langs->transnoentitiesnoconv("Core"), 'external'=>$langs->transnoentitiesnoconv("External").' - '.$langs->trans("AllPublishers"));
 
 // Search modules dirs
 $modulesdir = dolGetModulesDirs();
@@ -76,30 +76,30 @@ $modules = array();
 $orders = array();
 $categ = array();
 $dirmod = array();
-$i = 0;	// is a sequencer of modules found
-$j = 0;	// j is module number. Automatically affected if module number not defined.
-$modNameLoaded=array();
+$i = 0; // is a sequencer of modules found
+$j = 0; // j is module number. Automatically affected if module number not defined.
+$modNameLoaded = array();
 
 foreach ($modulesdir as $dir)
 {
 	// Load modules attributes in arrays (name, numero, orders) from dir directory
 	//print $dir."\n<br>";
 	dol_syslog("Scan directory ".$dir." for module descriptor files (modXXX.class.php)");
-	$handle=@opendir($dir);
+	$handle = @opendir($dir);
 	if (is_resource($handle))
 	{
-		while (($file = readdir($handle))!==false)
+		while (($file = readdir($handle)) !== false)
 		{
 			//print "$i ".$file."\n<br>";
-		    if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod'  && substr($file, dol_strlen($file) - 10) == '.class.php')
+		    if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php')
 		    {
 		        $modName = substr($file, 0, dol_strlen($file) - 10);
 
 		        if ($modName)
 		        {
-		        	if (! empty($modNameLoaded[$modName]))
+		        	if (!empty($modNameLoaded[$modName]))
 		        	{
-		        		$mesg="Error: Module ".$modName." was found twice: Into ".$modNameLoaded[$modName]." and ".$dir.". You probably have an old file on your disk.<br>";
+		        		$mesg = "Error: Module ".$modName." was found twice: Into ".$modNameLoaded[$modName]." and ".$dir.". You probably have an old file on your disk.<br>";
 		        		setEventMessages($mesg, null, 'warnings');
 		        		dol_syslog($mesg, LOG_ERR);
 						continue;
@@ -107,43 +107,43 @@ foreach ($modulesdir as $dir)
 
 		            try
 		            {
-		                $res=include_once $dir.$file;
+		                $res = include_once $dir.$file;
 		                if (class_exists($modName))
 						{
 							try {
 				                $objMod = new $modName($db);
-								$modNameLoaded[$modName]=$dir;
+								$modNameLoaded[$modName] = $dir;
 
-    		    		        if (! $objMod->numero > 0 && $modName != 'modUser')
+    		    		        if (!$objMod->numero > 0 && $modName != 'modUser')
     		            		{
     		         		    	dol_syslog('The module descriptor '.$modName.' must have a numero property', LOG_ERR);
     		            		}
 								$j = $objMod->numero;
 
-    							$modulequalified=1;
+    							$modulequalified = 1;
 
 		    					// We discard modules according to features level (PS: if module is activated we always show it)
 		    					$const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i', '', get_class($objMod)));
-		    					if ($objMod->version == 'development'  && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 2))) $modulequalified=0;
-		    					if ($objMod->version == 'experimental' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 1))) $modulequalified=0;
-								if (preg_match('/deprecated/', $objMod->version) && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL >= 0))) $modulequalified=0;
+		    					if ($objMod->version == 'development' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 2))) $modulequalified = 0;
+		    					if ($objMod->version == 'experimental' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 1))) $modulequalified = 0;
+								if (preg_match('/deprecated/', $objMod->version) && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL >= 0))) $modulequalified = 0;
 
 		    					// We discard modules according to property disabled
 		    					//if (! empty($objMod->hidden)) $modulequalified=0;
 
 		    					if ($modulequalified > 0)
 		    					{
-		    					    $publisher=dol_escape_htmltag($objMod->getPublisher());
-		    					    $external=($objMod->isCoreOrExternalModule() == 'external');
+		    					    $publisher = dol_escape_htmltag($objMod->getPublisher());
+		    					    $external = ($objMod->isCoreOrExternalModule() == 'external');
 		    					    if ($external)
 		    					    {
 		    					        if ($publisher)
 		    					        {
-		    					            $arrayofnatures['external_'.$publisher]=$langs->trans("External").' - '.$publisher;
+		    					            $arrayofnatures['external_'.$publisher] = $langs->trans("External").' - '.$publisher;
 		    					        }
 		    					        else
 		    					        {
-		    					            $arrayofnatures['external_']=$langs->trans("External").' - '.$langs->trans("UnknownPublishers");
+		    					            $arrayofnatures['external_'] = $langs->trans("External").' - '.$langs->trans("UnknownPublishers");
 		    					        }
 		    					    }
 		    					    ksort($arrayofnatures);
@@ -153,37 +153,37 @@ foreach ($modulesdir as $dir)
 		    					if ($modulequalified > 0)
 		    					{
 		    						$modules[$i] = $objMod;
-		    			            $filename[$i]= $modName;
+		    			            $filename[$i] = $modName;
 
 		    			            // Gives the possibility to the module, to provide his own family info and position of this family
 		    			            if (is_array($objMod->familyinfo) && !empty($objMod->familyinfo)) {
-		    			            	if (!is_array($familyinfo)) $familyinfo=array();
+		    			            	if (!is_array($familyinfo)) $familyinfo = array();
 		    			            	$familyinfo = array_merge($familyinfo, $objMod->familyinfo);
 		    			            	$familykey = key($objMod->familyinfo);
 		    			            } else {
 		    			            	$familykey = $objMod->family;
 		    			            }
 
-		    			            $moduleposition = ($objMod->module_position?$objMod->module_position:'50');
+		    			            $moduleposition = ($objMod->module_position ? $objMod->module_position : '50');
 		    			            if ($moduleposition == '50' && ($objMod->isCoreOrExternalModule() == 'external'))
 		    			            {
-		    			                $moduleposition = '80';		// External modules at end by default
+		    			                $moduleposition = '80'; // External modules at end by default
 		    			            }
 
-		    			            $orders[$i]  = $familyinfo[$familykey]['position']."_".$familykey."_".$moduleposition."_".$j;   // Sort by family, then by module position then number
-		    						$dirmod[$i]  = $dir;
+		    			            $orders[$i] = $familyinfo[$familykey]['position']."_".$familykey."_".$moduleposition."_".$j; // Sort by family, then by module position then number
+		    						$dirmod[$i] = $dir;
 		    						//print $i.'-'.$dirmod[$i].'<br>';
 		    			            // Set categ[$i]
 		    						$specialstring = 'unknown';
-		    			            if ($objMod->version == 'development' || $objMod->version == 'experimental') $specialstring='expdev';
-		    						if (isset($categ[$specialstring])) $categ[$specialstring]++;					// Array of all different modules categories
-		    			            else $categ[$specialstring]=1;
+		    			            if ($objMod->version == 'development' || $objMod->version == 'experimental') $specialstring = 'expdev';
+		    						if (isset($categ[$specialstring])) $categ[$specialstring]++; // Array of all different modules categories
+		    			            else $categ[$specialstring] = 1;
 		    						$j++;
 		    			            $i++;
 		    					}
 		    					else dol_syslog("Module ".get_class($objMod)." not qualified");
 							}
-		            		catch(Exception $e)
+		            		catch (Exception $e)
 		            		{
 		            		     dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR);
 		            		}
@@ -193,7 +193,7 @@ foreach ($modulesdir as $dir)
 							print "Warning bad descriptor file : ".$dir.$file." (Class ".$modName." not found into file)<br>";
 						}
 					}
-		            catch(Exception $e)
+		            catch (Exception $e)
 		            {
 		                 dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR);
 		            }
@@ -215,8 +215,8 @@ asort($orders);
 
 
 unset($objMod);
-$i=0;
-foreach($orders as $tmpkey => $tmpvalue)
+$i = 0;
+foreach ($orders as $tmpkey => $tmpvalue)
 {
     $tmpMod  = $modules[$tmpkey];
     if ($tmpMod->numero == $id)
@@ -230,54 +230,54 @@ foreach($orders as $tmpkey => $tmpvalue)
     $i++;
 }
 $value = $orders[$key];
-$tab=explode('_', $value);
-$familyposition=$tab[0]; $familykey=$tab[1]; $module_position=$tab[2]; $numero=$tab[3];
+$tab = explode('_', $value);
+$familyposition = $tab[0]; $familykey = $tab[1]; $module_position = $tab[2]; $numero = $tab[3];
 
 
 
 $head = modulehelp_prepare_head($objMod);
 
 // Check filters
-$modulename=$objMod->getName();
-$moduledesc=$objMod->getDesc();
-$moduleauthor=$objMod->getPublisher();
-$moduledir=strtolower(preg_replace('/^mod/i', '', get_class($objMod)));
+$modulename = $objMod->getName();
+$moduledesc = $objMod->getDesc();
+$moduleauthor = $objMod->getPublisher();
+$moduledir = strtolower(preg_replace('/^mod/i', '', get_class($objMod)));
 
 $const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i', '', get_class($objMod)));
 
 $text = '<span class="opacitymedium">'.$langs->trans("LastActivationDate").':</span> ';
-if (! empty($conf->global->$const_name)) $text.=dol_print_date($objMod->getLastActivationDate(), 'dayhour');
-else $text.=$langs->trans("Disabled");
+if (!empty($conf->global->$const_name)) $text .= dol_print_date($objMod->getLastActivationDate(), 'dayhour');
+else $text .= $langs->trans("Disabled");
 $tmp = $objMod->getLastActivationInfo();
 $authorid = $tmp['authorid'];
 if ($authorid > 0)
 {
 	$tmpuser = new User($db);
 	$tmpuser->fetch($authorid);
-	$text.='<br><span class="opacitymedium">'.$langs->trans("LastActivationAuthor").':</span> ';
-	$text.= $tmpuser->getNomUrl(1);
+	$text .= '<br><span class="opacitymedium">'.$langs->trans("LastActivationAuthor").':</span> ';
+	$text .= $tmpuser->getNomUrl(1);
 }
 $ip = $tmp['ip'];
 if ($ip)
 {
-	$text.='<br><span class="opacitymedium">'.$langs->trans("LastActivationIP").':</span> ';
-	$text.= $ip;
+	$text .= '<br><span class="opacitymedium">'.$langs->trans("LastActivationIP").':</span> ';
+	$text .= $ip;
 }
 
 $moreinfo = $text;
 
-$title = ($modulename?$modulename:$moduledesc);
+$title = ($modulename ? $modulename : $moduledesc);
 
 print '<div class="centpercent">';
 
 $picto = 'object_'.$objMod->picto;
 
-print load_fiche_titre(($modulename?$modulename:$moduledesc), $moreinfo, $picto);
+print load_fiche_titre(($modulename ? $modulename : $moduledesc), $moreinfo, $picto);
 print '<br>';
 
 dol_fiche_head($head, $mode, '', -1);
 
-if (! $modulename)
+if (!$modulename)
 {
 	dol_syslog("Error for module ".$key." - Property name of module looks empty", LOG_WARNING);
 }
@@ -285,7 +285,7 @@ if (! $modulename)
 // Load all lang files of module
 if (isset($objMod->langfiles) && is_array($objMod->langfiles))
 {
-	foreach($objMod->langfiles as $domain)
+	foreach ($objMod->langfiles as $domain)
 	{
 		$langs->load($domain);
 	}
@@ -295,197 +295,197 @@ if (isset($objMod->langfiles) && is_array($objMod->langfiles))
 
 
 // Version (with picto warning or not)
-$version=$objMod->getVersion(0);
-$versiontrans='';
-if (preg_match('/development/i', $version))  $versiontrans.=img_warning($langs->trans("Development"), 'style="float: left"');
-if (preg_match('/experimental/i', $version)) $versiontrans.=img_warning($langs->trans("Experimental"), 'style="float: left"');
-if (preg_match('/deprecated/i', $version))   $versiontrans.=img_warning($langs->trans("Deprecated"), 'style="float: left"');
-$versiontrans.=$objMod->getVersion(1);
+$version = $objMod->getVersion(0);
+$versiontrans = '';
+if (preg_match('/development/i', $version))  $versiontrans .= img_warning($langs->trans("Development"), 'style="float: left"');
+if (preg_match('/experimental/i', $version)) $versiontrans .= img_warning($langs->trans("Experimental"), 'style="float: left"');
+if (preg_match('/deprecated/i', $version))   $versiontrans .= img_warning($langs->trans("Deprecated"), 'style="float: left"');
+$versiontrans .= $objMod->getVersion(1);
 
 // Define imginfo
-$imginfo="info";
+$imginfo = "info";
 if ($objMod->isCoreOrExternalModule() == 'external')
 {
-    $imginfo="info_black";
+    $imginfo = "info_black";
 }
 
 // Define text of description of module
-$text='';
+$text = '';
 
 if ($mode == 'desc')
 {
     if ($moduledesc) $text .= '<br>'.$moduledesc.'<br><br><br>';
 
-    $text.='<span class="opacitymedium">'.$langs->trans("Version").':</span> '.$version;
+    $text .= '<span class="opacitymedium">'.$langs->trans("Version").':</span> '.$version;
 
-    $textexternal='';
+    $textexternal = '';
     if ($objMod->isCoreOrExternalModule() == 'external')
     {
-        $textexternal.='<br><span class="opacitymedium">'.$langs->trans("Origin").':</span> '.$langs->trans("ExternalModule", $dirofmodule);
-        if ($objMod->editor_name != 'dolibarr') $textexternal.='<br><span class="opacitymedium">'.$langs->trans("Publisher").':</span> '.(empty($objMod->editor_name)?$langs->trans("Unknown"):$objMod->editor_name);
+        $textexternal .= '<br><span class="opacitymedium">'.$langs->trans("Origin").':</span> '.$langs->trans("ExternalModule", $dirofmodule);
+        if ($objMod->editor_name != 'dolibarr') $textexternal .= '<br><span class="opacitymedium">'.$langs->trans("Publisher").':</span> '.(empty($objMod->editor_name) ? $langs->trans("Unknown") : $objMod->editor_name);
         $editor_url = $objMod->editor_url;
-        if (! preg_match('/^http/', $editor_url)) $editor_url = 'http://'.$editor_url;
-        if (! empty($objMod->editor_url) && ! preg_match('/dolibarr\.org/i', $objMod->editor_url)) $textexternal.= ($objMod->editor_name != 'dolibarr' ? ' - ' : '').img_picto('', 'globe').' <a href="'.$editor_url.'" target="_blank">'.$objMod->editor_url.'</a>';
-        $text.=$textexternal;
-        $text.='<br>';
+        if (!preg_match('/^http/', $editor_url)) $editor_url = 'http://'.$editor_url;
+        if (!empty($objMod->editor_url) && !preg_match('/dolibarr\.org/i', $objMod->editor_url)) $textexternal .= ($objMod->editor_name != 'dolibarr' ? ' - ' : '').img_picto('', 'globe').' <a href="'.$editor_url.'" target="_blank">'.$objMod->editor_url.'</a>';
+        $text .= $textexternal;
+        $text .= '<br>';
     }
     else
     {
-        $text.='<br><span class="opacitymedium">'.$langs->trans("Origin").':</span> '.$langs->trans("Core").'<br>';
+        $text .= '<br><span class="opacitymedium">'.$langs->trans("Origin").':</span> '.$langs->trans("Core").'<br>';
     }
 
-    $moduledesclong=$objMod->getDescLong();
-    if ($moduledesclong) $text.='<br><hr><div class="moduledesclong">'.$moduledesclong.'<div>';
+    $moduledesclong = $objMod->getDescLong();
+    if ($moduledesclong) $text .= '<br><hr><div class="moduledesclong">'.$moduledesclong.'<div>';
 }
 
 if ($mode == 'feature')
 {
-    $text.='<br><strong>'.$langs->trans("DependsOn").':</strong> ';
-    if (count($objMod->depends)) $text.=join(',', $objMod->depends);
-	else $text.=$langs->trans("None");
-    $text.='<br><strong>'.$langs->trans("RequiredBy").':</strong> ';
-	if (count($objMod->requiredby)) $text.=join(',', $objMod->requiredby);
-	else $text.=$langs->trans("None");
+    $text .= '<br><strong>'.$langs->trans("DependsOn").':</strong> ';
+    if (count($objMod->depends)) $text .= join(',', $objMod->depends);
+	else $text .= $langs->trans("None");
+    $text .= '<br><strong>'.$langs->trans("RequiredBy").':</strong> ';
+	if (count($objMod->requiredby)) $text .= join(',', $objMod->requiredby);
+	else $text .= $langs->trans("None");
 
-    $text.='<br><br>';
+    $text .= '<br><br>';
 
-    $text.='<br><strong>'.$langs->trans("AddDataTables").':</strong> ';
+    $text .= '<br><strong>'.$langs->trans("AddDataTables").':</strong> ';
 	$sqlfiles = dol_dir_list(dol_buildpath($moduledir.'/sql/'), 'files', 0, 'llx.*\.sql', array('\.key\.sql'));
     if (count($sqlfiles) > 0)
     {
-    	$text.=$langs->trans("Yes").' (';
-    	$i=0;
-    	foreach($sqlfiles as $val)
+    	$text .= $langs->trans("Yes").' (';
+    	$i = 0;
+    	foreach ($sqlfiles as $val)
     	{
-    		$text.=($i?', ':'').preg_replace('/\.sql$/', '', preg_replace('/llx_/', '', $val['name']));
+    		$text .= ($i ? ', ' : '').preg_replace('/\.sql$/', '', preg_replace('/llx_/', '', $val['name']));
     		$i++;
     	}
-    	$text.=')';
+    	$text .= ')';
     }
-    else $text.=$langs->trans("No");
+    else $text .= $langs->trans("No");
 
-    $text.='<br>';
+    $text .= '<br>';
 
-    $text.='<br><strong>'.$langs->trans("AddDictionaries").':</strong> ';
+    $text .= '<br><strong>'.$langs->trans("AddDictionaries").':</strong> ';
     if (isset($objMod->dictionaries) && isset($objMod->dictionaries['tablib']) && is_array($objMod->dictionaries['tablib']) && count($objMod->dictionaries['tablib']))
     {
-        $i=0;
-        foreach($objMod->dictionaries['tablib'] as $val)
+        $i = 0;
+        foreach ($objMod->dictionaries['tablib'] as $val)
         {
-            $text.=($i?', ':'').$val;
+            $text .= ($i ? ', ' : '').$val;
             $i++;
         }
     }
-    else $text.=$langs->trans("No");
+    else $text .= $langs->trans("No");
 
-    $text.='<br>';
+    $text .= '<br>';
 
-    $text.='<br><strong>'.$langs->trans("AddData").':</strong> ';
+    $text .= '<br><strong>'.$langs->trans("AddData").':</strong> ';
     $filedata = dol_buildpath($moduledir.'/sql/data.sql');
     if (dol_is_file($filedata))
     {
-        $text.=$langs->trans("Yes").' ('.$moduledir.'/sql/data.sql'.')';
+        $text .= $langs->trans("Yes").' ('.$moduledir.'/sql/data.sql'.')';
     }
-    else $text.=$langs->trans("No");
+    else $text .= $langs->trans("No");
 
-    $text.='<br>';
+    $text .= '<br>';
 
-    $text.='<br><strong>'.$langs->trans("AddRemoveTabs").':</strong> ';
+    $text .= '<br><strong>'.$langs->trans("AddRemoveTabs").':</strong> ';
     if (isset($objMod->tabs) && is_array($objMod->tabs) && count($objMod->tabs))
     {
-        $i=0;
-        foreach($objMod->tabs as $val)
+        $i = 0;
+        foreach ($objMod->tabs as $val)
         {
-        	if (is_array($val)) $val=$val['data'];
+        	if (is_array($val)) $val = $val['data'];
         	if (is_string($val))
         	{
-            	$tmp=explode(':', $val, 3);
-            	$text.=($i?', ':'').$tmp[0].':'.$tmp[1];
+            	$tmp = explode(':', $val, 3);
+            	$text .= ($i ? ', ' : '').$tmp[0].':'.$tmp[1];
            		$i++;
         	}
         }
     }
-    else $text.=$langs->trans("No");
+    else $text .= $langs->trans("No");
 
-    $text.='<br>';
+    $text .= '<br>';
 
-    $text.='<br><strong>'.$langs->trans("AddModels").':</strong> ';
+    $text .= '<br><strong>'.$langs->trans("AddModels").':</strong> ';
     if (isset($objMod->module_parts) && isset($objMod->module_parts['models']) && $objMod->module_parts['models'])
     {
-        $text.=$langs->trans("Yes");
+        $text .= $langs->trans("Yes");
     }
-    else $text.=$langs->trans("No");
+    else $text .= $langs->trans("No");
 
-    $text.='<br>';
+    $text .= '<br>';
 
-    $text.='<br><strong>'.$langs->trans("AddSubstitutions").':</strong> ';
+    $text .= '<br><strong>'.$langs->trans("AddSubstitutions").':</strong> ';
     if (isset($objMod->module_parts) && isset($objMod->module_parts['substitutions']) && $objMod->module_parts['substitutions'])
     {
-        $text.=$langs->trans("Yes");
+        $text .= $langs->trans("Yes");
     }
-    else $text.=$langs->trans("No");
+    else $text .= $langs->trans("No");
 
-    $text.='<br>';
+    $text .= '<br>';
 
-    $text.='<br><strong>'.$langs->trans("AddSheduledJobs").':</strong> ';
+    $text .= '<br><strong>'.$langs->trans("AddSheduledJobs").':</strong> ';
     if (isset($objMod->cronjobs) && is_array($objMod->cronjobs) && count($objMod->cronjobs))
     {
-        $i=0;
-        foreach($objMod->cronjobs as $val)
+        $i = 0;
+        foreach ($objMod->cronjobs as $val)
         {
-            $text.=($i?', ':'').($val['label']);
+            $text .= ($i ? ', ' : '').($val['label']);
             $i++;
         }
     }
-    else $text.=$langs->trans("No");
+    else $text .= $langs->trans("No");
 
-    $text.='<br>';
+    $text .= '<br>';
 
-    $text.='<br><strong>'.$langs->trans("AddTriggers").':</strong> ';
-    $moreinfoontriggerfile='';
+    $text .= '<br><strong>'.$langs->trans("AddTriggers").':</strong> ';
+    $moreinfoontriggerfile = '';
     if (isset($objMod->module_parts) && isset($objMod->module_parts['triggers']) && $objMod->module_parts['triggers'])
     {
-    	$yesno='Yes';
+    	$yesno = 'Yes';
     }
     else
     {
-    	$yesno='No';
+    	$yesno = 'No';
     }
     require_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php';
     $interfaces = new Interfaces($db);
-    $triggers = $interfaces->getTriggersList(array((($objMod->isCoreOrExternalModule() == 'external')?'/'.$moduledir:'').'/core/triggers'));
-	foreach($triggers as $triggercursor)
+    $triggers = $interfaces->getTriggersList(array((($objMod->isCoreOrExternalModule() == 'external') ? '/'.$moduledir : '').'/core/triggers'));
+	foreach ($triggers as $triggercursor)
 	{
 		if ($triggercursor['module'] == $moduledir)
 		{
-			$yesno='Yes';
-			$moreinfoontriggerfile=' ('.$triggercursor['relpath'].')';
+			$yesno = 'Yes';
+			$moreinfoontriggerfile = ' ('.$triggercursor['relpath'].')';
 		}
 	}
 
-    $text.=$langs->trans($yesno).$moreinfoontriggerfile;
+    $text .= $langs->trans($yesno).$moreinfoontriggerfile;
 
-    $text.='<br>';
+    $text .= '<br>';
 
-    $text.='<br><strong>'.$langs->trans("AddBoxes").':</strong> ';
+    $text .= '<br><strong>'.$langs->trans("AddBoxes").':</strong> ';
     if (isset($objMod->boxes) && is_array($objMod->boxes) && count($objMod->boxes))
     {
-        $i=0;
-        foreach($objMod->boxes as $val)
+        $i = 0;
+        foreach ($objMod->boxes as $val)
         {
-            $text.=($i?', ':'').($val['file']?$val['file']:$val[0]);
+            $text .= ($i ? ', ' : '').($val['file'] ? $val['file'] : $val[0]);
             $i++;
         }
     }
-    else $text.=$langs->trans("No");
+    else $text .= $langs->trans("No");
 
-    $text.='<br>';
+    $text .= '<br>';
 
-    $text.='<br><strong>'.$langs->trans("AddHooks").':</strong> ';
+    $text .= '<br><strong>'.$langs->trans("AddHooks").':</strong> ';
     if (isset($objMod->module_parts) && is_array($objMod->module_parts['hooks']) && count($objMod->module_parts['hooks']))
     {
-    	$i=0;
-        foreach($objMod->module_parts['hooks'] as $key => $val)
+    	$i = 0;
+        foreach ($objMod->module_parts['hooks'] as $key => $val)
         {
         	if ($key === 'entity') continue;
 
@@ -494,9 +494,9 @@ if ($mode == 'feature')
         	{
         		if (is_array($val))
         		{
-        			foreach($val as $value)
+        			foreach ($val as $value)
         			{
-        				$text.=($i?', ':'').($value);
+        				$text .= ($i ? ', ' : '').($value);
         				$i++;
         			}
 
@@ -504,75 +504,75 @@ if ($mode == 'feature')
         		}
         	}
 
-        	$text.=($i?', ':'').($val);
+        	$text .= ($i ? ', ' : '').($val);
         	$i++;
         }
     }
-    else $text.=$langs->trans("No");
+    else $text .= $langs->trans("No");
 
-    $text.='<br>';
+    $text .= '<br>';
 
-    $text.='<br><strong>'.$langs->trans("AddPermissions").':</strong> ';
+    $text .= '<br><strong>'.$langs->trans("AddPermissions").':</strong> ';
     if (isset($objMod->rights) && is_array($objMod->rights) && count($objMod->rights))
     {
-        $i=0;
-        foreach($objMod->rights as $val)
+        $i = 0;
+        foreach ($objMod->rights as $val)
         {
-        	$text.=($i?', ':'').($val[1]);
+        	$text .= ($i ? ', ' : '').($val[1]);
         	$i++;
         }
     }
-    else $text.=$langs->trans("No");
+    else $text .= $langs->trans("No");
 
-    $text.='<br>';
+    $text .= '<br>';
 
-    $text.='<br><strong>'.$langs->trans("AddMenus").':</strong> ';
-    if (isset($objMod->menu) && ! empty($objMod->menu)) // objMod can be an array or just an int 1
+    $text .= '<br><strong>'.$langs->trans("AddMenus").':</strong> ';
+    if (isset($objMod->menu) && !empty($objMod->menu)) // objMod can be an array or just an int 1
     {
-        $text.=$langs->trans("Yes");
+        $text .= $langs->trans("Yes");
     }
-    else $text.=$langs->trans("No");
+    else $text .= $langs->trans("No");
 
-    $text.='<br>';
+    $text .= '<br>';
 
-    $text.='<br><strong>'.$langs->trans("AddExportProfiles").':</strong> ';
+    $text .= '<br><strong>'.$langs->trans("AddExportProfiles").':</strong> ';
     if (isset($objMod->export_label) && is_array($objMod->export_label) && count($objMod->export_label))
     {
-        $i=0;
-        foreach($objMod->export_label as $val)
+        $i = 0;
+        foreach ($objMod->export_label as $val)
         {
-            $text.=($i?', ':'').($val);
+            $text .= ($i ? ', ' : '').($val);
             $i++;
         }
     }
-    else $text.=$langs->trans("No");
+    else $text .= $langs->trans("No");
 
-    $text.='<br>';
+    $text .= '<br>';
 
-    $text.='<br><strong>'.$langs->trans("AddImportProfiles").':</strong> ';
+    $text .= '<br><strong>'.$langs->trans("AddImportProfiles").':</strong> ';
     if (isset($objMod->import_label) && is_array($objMod->import_label) && count($objMod->import_label))
     {
-        $i=0;
-        foreach($objMod->import_label as $val)
+        $i = 0;
+        foreach ($objMod->import_label as $val)
         {
-            $text.=($i?', ':'').($val);
+            $text .= ($i ? ', ' : '').($val);
             $i++;
         }
     }
-    else $text.=$langs->trans("No");
+    else $text .= $langs->trans("No");
 
-    $text.='<br>';
+    $text .= '<br>';
 
-    $text.='<br><strong>'.$langs->trans("AddOtherPagesOrServices").':</strong> ';
-    $text.=$langs->trans("DetectionNotPossible");
+    $text .= '<br><strong>'.$langs->trans("AddOtherPagesOrServices").':</strong> ';
+    $text .= $langs->trans("DetectionNotPossible");
 }
 
 
 if ($mode == 'changelog')
 {
-    $changelog=$objMod->getChangeLog();
-    if ($changelog) $text.='<div class="moduledesclong">'.$changelog.'<div>';
-    else $text.='<div class="moduledesclong">'.$langs->trans("NotAvailable").'</div>';
+    $changelog = $objMod->getChangeLog();
+    if ($changelog) $text .= '<div class="moduledesclong">'.$changelog.'<div>';
+    else $text .= '<div class="moduledesclong">'.$langs->trans("NotAvailable").'</div>';
 }
 
 print $text;

+ 17 - 17
htdocs/admin/modules.php

@@ -1010,19 +1010,19 @@ if ($mode == 'deploy')
 {
 	dol_fiche_head($head, $mode, '', -1);
 
-	$dolibarrdataroot=preg_replace('/([\\/]+)$/i', '', DOL_DATA_ROOT);
-	$allowonlineinstall=true;
-	$allowfromweb=1;
-	if (dol_is_file($dolibarrdataroot.'/installmodules.lock')) $allowonlineinstall=false;
-
-	$fullurl='<a href="'.$urldolibarrmodules.'" target="_blank">'.$urldolibarrmodules.'</a>';
-	$message='';
-	if (! empty($allowonlineinstall))
+	$dolibarrdataroot = preg_replace('/([\\/]+)$/i', '', DOL_DATA_ROOT);
+	$allowonlineinstall = true;
+	$allowfromweb = 1;
+	if (dol_is_file($dolibarrdataroot.'/installmodules.lock')) $allowonlineinstall = false;
+
+	$fullurl = '<a href="'.$urldolibarrmodules.'" target="_blank">'.$urldolibarrmodules.'</a>';
+	$message = '';
+	if (!empty($allowonlineinstall))
 	{
-		if (! in_array('/custom', explode(',', $dolibarr_main_url_root_alt)))
+		if (!in_array('/custom', explode(',', $dolibarr_main_url_root_alt)))
 		{
-			$message=info_admin($langs->trans("ConfFileMustContainCustom", DOL_DOCUMENT_ROOT.'/custom', DOL_DOCUMENT_ROOT));
-			$allowfromweb=-1;
+			$message = info_admin($langs->trans("ConfFileMustContainCustom", DOL_DOCUMENT_ROOT.'/custom', DOL_DOCUMENT_ROOT));
+			$allowfromweb = -1;
 		}
 		else
 		{
@@ -1031,21 +1031,21 @@ if ($mode == 'deploy')
 				if (!is_writable(dol_osencode($dirins)))
 				{
 					$langs->load("errors");
-					$message=info_admin($langs->trans("ErrorFailedToWriteInDir", $dirins), 0, 0, '1', 'warning');
-					$allowfromweb=0;
+					$message = info_admin($langs->trans("ErrorFailedToWriteInDir", $dirins), 0, 0, '1', 'warning');
+					$allowfromweb = 0;
 				}
 			}
 			else
 			{
-				$message=info_admin($langs->trans("NotExistsDirect", $dirins).$langs->trans("InfDirAlt").$langs->trans("InfDirExample"));
-				$allowfromweb=0;
+				$message = info_admin($langs->trans("NotExistsDirect", $dirins).$langs->trans("InfDirAlt").$langs->trans("InfDirExample"));
+				$allowfromweb = 0;
 			}
 		}
 	}
 	else
 	{
-		$message=info_admin($langs->trans("InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.'/installmodules.lock'));
-		$allowfromweb=0;
+		$message = info_admin($langs->trans("InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.'/installmodules.lock'));
+		$allowfromweb = 0;
 	}
 
 	if ($allowfromweb < 1)

+ 17 - 17
htdocs/admin/openinghours.php

@@ -25,27 +25,27 @@ require '../main.inc.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
 
-$action=GETPOST('action', 'aZ09');
-$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'adminaccoutant';   // To manage different context of search
+$action = GETPOST('action', 'aZ09');
+$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'adminaccoutant'; // To manage different context of search
 
 // Load translation files required by the page
 $langs->loadLangs(array('admin', 'companies', 'other'));
 
-if (! $user->admin) accessforbidden();
+if (!$user->admin) accessforbidden();
 
-$error=0;
+$error = 0;
 
 
 /*
  * 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 == 'update' && ! GETPOST("cancel", 'alpha'))
-|| ($action == 'updateedit') )
+if (($action == 'update' && !GETPOST("cancel", 'alpha'))
+|| ($action == 'updateedit'))
 {
 	dolibarr_set_const($db, "MAIN_INFO_OPENINGHOURS_MONDAY", GETPOST("monday", 'alpha'), 'chaine', 0, '', $conf->entity);
 	dolibarr_set_const($db, "MAIN_INFO_OPENINGHOURS_TUESDAY", GETPOST("tuesday", 'alpha'), 'chaine', 0, '', $conf->entity);
@@ -55,7 +55,7 @@ if ( ($action == 'update' && ! GETPOST("cancel", 'alpha'))
 	dolibarr_set_const($db, "MAIN_INFO_OPENINGHOURS_SATURDAY", GETPOST("saturday", 'alpha'), 'chaine', 0, '', $conf->entity);
 	dolibarr_set_const($db, "MAIN_INFO_OPENINGHOURS_SUNDAY", GETPOST('sunday', 'alpha'), 'chaine', 0, '', $conf->entity);
 
-	if ($action != 'updateedit' && ! $error)
+	if ($action != 'updateedit' && !$error)
 	{
 		header("Location: ".$_SERVER["PHP_SELF"]);
 		exit;
@@ -68,7 +68,7 @@ if ( ($action == 'update' && ! GETPOST("cancel", 'alpha'))
 
 $form = new Form($db);
 
-$help_url='';
+$help_url = '';
 llxHeader('', $langs->trans("CompanyFoundation"), $help_url);
 
 print load_fiche_titre($langs->trans("CompanyFoundation"), '', 'title_setup');
@@ -95,37 +95,37 @@ if (empty($action) || $action == 'edit' || $action == 'updateedit')
 	print '<tr class="oddeven"><td>';
 	print $form->textwithpicto($langs->trans("Monday"), $langs->trans("OpeningHoursFormatDesc"));
 	print '</td><td>';
-	print '<input name="monday" id="monday" class="minwidth100" value="'. ($conf->global->MAIN_INFO_OPENINGHOURS_MONDAY?$conf->global->MAIN_INFO_OPENINGHOURS_MONDAY: GETPOST("monday", 'alpha')) . '"'.(empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '' : ' autofocus="autofocus"').'></td></tr>'."\n";
+	print '<input name="monday" id="monday" class="minwidth100" value="'.($conf->global->MAIN_INFO_OPENINGHOURS_MONDAY ? $conf->global->MAIN_INFO_OPENINGHOURS_MONDAY : GETPOST("monday", 'alpha')).'"'.(empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '' : ' autofocus="autofocus"').'></td></tr>'."\n";
 
     print '<tr class="oddeven"><td>';
     print $form->textwithpicto($langs->trans("Tuesday"), $langs->trans("OpeningHoursFormatDesc"));
     print '</td><td>';
-    print '<input name="tuesday" id="tuesday" class="minwidth100" value="'. ($conf->global->MAIN_INFO_OPENINGHOURS_TUESDAY?$conf->global->MAIN_INFO_OPENINGHOURS_TUESDAY: GETPOST("tuesday", 'alpha')) . '"></td></tr>'."\n";
+    print '<input name="tuesday" id="tuesday" class="minwidth100" value="'.($conf->global->MAIN_INFO_OPENINGHOURS_TUESDAY ? $conf->global->MAIN_INFO_OPENINGHOURS_TUESDAY : GETPOST("tuesday", 'alpha')).'"></td></tr>'."\n";
 
     print '<tr class="oddeven"><td>';
     print $form->textwithpicto($langs->trans("Wednesday"), $langs->trans("OpeningHoursFormatDesc"));
     print '</td><td>';
-    print '<input name="wednesday" id="wednesday" class="minwidth100" value="'. ($conf->global->MAIN_INFO_OPENINGHOURS_WEDNESDAY?$conf->global->MAIN_INFO_OPENINGHOURS_WEDNESDAY: GETPOST("wednesday", 'alpha')) . '"></td></tr>'."\n";
+    print '<input name="wednesday" id="wednesday" class="minwidth100" value="'.($conf->global->MAIN_INFO_OPENINGHOURS_WEDNESDAY ? $conf->global->MAIN_INFO_OPENINGHOURS_WEDNESDAY : GETPOST("wednesday", 'alpha')).'"></td></tr>'."\n";
 
     print '<tr class="oddeven"><td>';
     print $form->textwithpicto($langs->trans("Thursday"), $langs->trans("OpeningHoursFormatDesc"));
     print '</td><td>';
-    print '<input name="thursday" id="thursday" class="minwidth100" value="'. ($conf->global->MAIN_INFO_OPENINGHOURS_THURSDAY?$conf->global->MAIN_INFO_OPENINGHOURS_THURSDAY: GETPOST("thursday", 'alpha')) . '"></td></tr>'."\n";
+    print '<input name="thursday" id="thursday" class="minwidth100" value="'.($conf->global->MAIN_INFO_OPENINGHOURS_THURSDAY ? $conf->global->MAIN_INFO_OPENINGHOURS_THURSDAY : GETPOST("thursday", 'alpha')).'"></td></tr>'."\n";
 
     print '<tr class="oddeven"><td>';
     print $form->textwithpicto($langs->trans("Friday"), $langs->trans("OpeningHoursFormatDesc"));
     print '</td><td>';
-    print '<input name="friday" id="friday" class="minwidth100" value="'. ($conf->global->MAIN_INFO_OPENINGHOURS_FRIDAY?$conf->global->MAIN_INFO_OPENINGHOURS_FRIDAY: GETPOST("friday", 'alpha')) . '"></td></tr>'."\n";
+    print '<input name="friday" id="friday" class="minwidth100" value="'.($conf->global->MAIN_INFO_OPENINGHOURS_FRIDAY ? $conf->global->MAIN_INFO_OPENINGHOURS_FRIDAY : GETPOST("friday", 'alpha')).'"></td></tr>'."\n";
 
     print '<tr class="oddeven"><td>';
     print $form->textwithpicto($langs->trans("Saturday"), $langs->trans("OpeningHoursFormatDesc"));
     print '</td><td>';
-    print '<input name="saturday" id="saturday" class="minwidth100" value="'. ($conf->global->MAIN_INFO_OPENINGHOURS_SATURDAY?$conf->global->MAIN_INFO_OPENINGHOURS_SATURDAY: GETPOST("saturday", 'alpha')) . '"></td></tr>'."\n";
+    print '<input name="saturday" id="saturday" class="minwidth100" value="'.($conf->global->MAIN_INFO_OPENINGHOURS_SATURDAY ? $conf->global->MAIN_INFO_OPENINGHOURS_SATURDAY : GETPOST("saturday", 'alpha')).'"></td></tr>'."\n";
 
     print '<tr class="oddeven"><td>';
     print $form->textwithpicto($langs->trans("Sunday"), $langs->trans("OpeningHoursFormatDesc"));
     print '</td><td>';
-    print '<input name="sunday" id="sunday" class="minwidth100" value="'. ($conf->global->MAIN_INFO_OPENINGHOURS_SUNDAY?$conf->global->MAIN_INFO_OPENINGHOURS_SUNDAY: GETPOST("sunday", 'alpha')) . '"></td></tr>'."\n";
+    print '<input name="sunday" id="sunday" class="minwidth100" value="'.($conf->global->MAIN_INFO_OPENINGHOURS_SUNDAY ? $conf->global->MAIN_INFO_OPENINGHOURS_SUNDAY : GETPOST("sunday", 'alpha')).'"></td></tr>'."\n";
 
     print '</table>';
 

+ 29 - 29
htdocs/admin/payment.php

@@ -29,13 +29,13 @@ require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
 // Load translation files required by the page
 $langs->loadLangs(array("admin", "other", "errors", "bills"));
 
-if (! $user->admin) accessforbidden();
+if (!$user->admin) accessforbidden();
 
 $action = GETPOST('action', 'alpha');
 $value = GETPOST('value', 'alpha');
 $label = GETPOST('label', 'alpha');
 $scandir = GETPOST('scan_dir', 'alpha');
-$type='invoice';
+$type = 'invoice';
 
 if (empty($conf->global->PAYMENT_ADDON)) $conf->global->PAYMENT_ADDON = 'mod_payment_cicada.php';
 
@@ -46,13 +46,13 @@ if (empty($conf->global->PAYMENT_ADDON)) $conf->global->PAYMENT_ADDON = 'mod_pay
 
 if ($action == 'updateMask')
 {
-    $maskconstpayment=GETPOST('maskconstpayment', 'alpha');
-    $maskpayment=GETPOST('maskpayment', 'alpha');
+    $maskconstpayment = GETPOST('maskconstpayment', 'alpha');
+    $maskpayment = GETPOST('maskpayment', 'alpha');
     if ($maskconstpayment) $res = dolibarr_set_const($db, $maskconstpayment, $maskpayment, 'chaine', 0, '', $conf->entity);
 
-    if (! $res > 0) $error++;
+    if (!$res > 0) $error++;
 
-    if (! $error)
+    if (!$error)
     {
         setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
     }
@@ -69,17 +69,17 @@ if ($action == 'setmod')
 
 if ($action == 'setparams')
 {
-	$freetext = GETPOST('FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS', 'none');	// No alpha here, we want exact string
+	$freetext = GETPOST('FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS', 'none'); // No alpha here, we want exact string
 
 	$res = dolibarr_set_const($db, "FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS", $freetext, 'chaine', 0, '', $conf->entity);
 
-	if (! $res > 0) $error++;
+	if (!$res > 0) $error++;
 
 	if ($error)
 	{
 		setEventMessages($langs->trans("Error"), null, 'errors');
 	}
-	if (! $error)
+	if (!$error)
 	{
 	    setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
 	}
@@ -90,14 +90,14 @@ if ($action == 'setparams')
  * View
  */
 
-$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']);
+$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
 
 llxHeader("", $langs->trans("BillsSetup"), 'EN:Invoice_Configuration|FR:Configuration_module_facture|ES:ConfiguracionFactura');
 
-$form=new Form($db);
+$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("BillsSetup"), $linkback, 'title_setup');
 
 $head = invoice_admin_prepare_head();
@@ -129,24 +129,24 @@ foreach ($dirmodels as $reldir)
         $handle = opendir($dir);
         if (is_resource($handle))
         {
-            while (($file = readdir($handle))!==false)
+            while (($file = readdir($handle)) !== false)
             {
-                if (! is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS'))
+                if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS'))
                 {
                     $filebis = $file;
                     $classname = preg_replace('/\.php$/', '', $file);
                     // For compatibility
-                    if (! is_file($dir.$filebis))
+                    if (!is_file($dir.$filebis))
                     {
                         $filebis = $file."/".$file.".modules.php";
                         $classname = "mod_payment_".$file;
                     }
                     // Check if there is a filter on country
                     preg_match('/\-(.*)_(.*)$/', $classname, $reg);
-                    if (! empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue;
+                    if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue;
 
                     $classname = preg_replace('/\-.*$/', '', $classname);
-                    if (! class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis)-3, 3) == 'php')
+                    if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php')
                     {
                         // Charging the numbering class
                         require_once $dir.$filebis;
@@ -154,7 +154,7 @@ foreach ($dirmodels as $reldir)
                         $module = new $classname($db);
 
                         // 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())
@@ -170,9 +170,9 @@ foreach ($dirmodels as $reldir)
 
                             // Show example of numbering module
                             print '<td class="nowrap">';
-                            $tmp=$module->getExample();
+                            $tmp = $module->getExample();
                             if (preg_match('/^Error/', $tmp)) 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";
 
@@ -188,21 +188,21 @@ foreach ($dirmodels as $reldir)
                             }
                             print '</td>';
 
-                            $payment=new Paiement($db);
+                            $payment = new Paiement($db);
                             $payment->initAsSpecimen();
 
                             // Example
-                            $htmltooltip='';
-                            $htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
-                            $nextval=$module->getNextValue($mysoc, $payment);
+                            $htmltooltip = '';
+                            $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
+                            $nextval = $module->getNextValue($mysoc, $payment);
                             if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
-                                    $htmltooltip.=$langs->trans("NextValue").': ';
+                                    $htmltooltip .= $langs->trans("NextValue").': ';
                                 if ($nextval) {
-                                    if (preg_match('/^Error/', $nextval) || $nextval=='NotConfigured')
+                                    if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
                                         $nextval = $langs->trans($nextval);
-                                    $htmltooltip.=$nextval.'<br>';
+                                    $htmltooltip .= $nextval.'<br>';
                                 } else {
-                                    $htmltooltip.=$langs->trans($module->error).'<br>';
+                                    $htmltooltip .= $langs->trans($module->error).'<br>';
                                 }
                             }
 
@@ -211,7 +211,7 @@ foreach ($dirmodels as $reldir)
 
                             if ($conf->global->PAYMENT_ADDON.'.php' == $file)  // If module is the one used, we show existing errors
                             {
-                                if (! empty($module->error)) dol_htmloutput_mesg($module->error, '', 'error', 1);
+                                if (!empty($module->error)) dol_htmloutput_mesg($module->error, '', 'error', 1);
                             }
 
                             print '</td>';

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.