Browse Source

add new rule

Frédéric FRANCE 5 years ago
parent
commit
b41ac00b98
100 changed files with 727 additions and 1456 deletions
  1. 2 4
      dev/examples/code/create_invoice.php
  2. 2 4
      dev/examples/code/create_order.php
  3. 2 4
      dev/examples/code/create_product.php
  4. 3 6
      dev/examples/code/create_user.php
  5. 5 10
      htdocs/accountancy/admin/account.php
  6. 27 54
      htdocs/accountancy/admin/accountmodel.php
  7. 7 14
      htdocs/accountancy/admin/card.php
  8. 30 60
      htdocs/accountancy/admin/categories_list.php
  9. 1 2
      htdocs/accountancy/admin/defaultaccounts.php
  10. 1 3
      htdocs/accountancy/admin/fiscalyear_card.php
  11. 17 34
      htdocs/accountancy/admin/journals_list.php
  12. 22 42
      htdocs/accountancy/admin/productaccount.php
  13. 6 15
      htdocs/accountancy/bookkeeping/card.php
  14. 12 24
      htdocs/accountancy/bookkeeping/list.php
  15. 8 16
      htdocs/accountancy/bookkeeping/listbyaccount.php
  16. 6 12
      htdocs/accountancy/class/accountancycategory.class.php
  17. 9 17
      htdocs/accountancy/class/accountancyexport.class.php
  18. 6 12
      htdocs/accountancy/class/accountingaccount.class.php
  19. 3 6
      htdocs/accountancy/class/accountingjournal.class.php
  20. 2 4
      htdocs/accountancy/class/bookkeeping.class.php
  21. 1 2
      htdocs/accountancy/customer/card.php
  22. 5 10
      htdocs/accountancy/customer/index.php
  23. 2 4
      htdocs/accountancy/customer/list.php
  24. 1 2
      htdocs/accountancy/expensereport/card.php
  25. 4 8
      htdocs/accountancy/expensereport/index.php
  26. 1 2
      htdocs/accountancy/expensereport/list.php
  27. 1 2
      htdocs/accountancy/index.php
  28. 28 56
      htdocs/accountancy/journal/bankjournal.php
  29. 11 22
      htdocs/accountancy/journal/expensereportsjournal.php
  30. 14 28
      htdocs/accountancy/journal/purchasesjournal.php
  31. 12 24
      htdocs/accountancy/journal/sellsjournal.php
  32. 1 2
      htdocs/accountancy/supplier/card.php
  33. 5 10
      htdocs/accountancy/supplier/index.php
  34. 2 4
      htdocs/accountancy/supplier/list.php
  35. 1 2
      htdocs/accountancy/tpl/export_journal.tpl.php
  36. 4 8
      htdocs/api/admin/index.php
  37. 2 4
      htdocs/api/class/api.class.php
  38. 2 4
      htdocs/api/class/api_access.class.php
  39. 1 2
      htdocs/api/class/api_login.class.php
  40. 12 24
      htdocs/api/class/api_setup.class.php
  41. 2 4
      htdocs/api/index.php
  42. 1 2
      htdocs/asset/admin/setup.php
  43. 2 4
      htdocs/asset/card.php
  44. 7 14
      htdocs/asset/class/asset.class.php
  45. 9 18
      htdocs/asset/class/asset_type.class.php
  46. 1 2
      htdocs/asset/document.php
  47. 2 4
      htdocs/asset/list.php
  48. 8 16
      htdocs/asset/type.php
  49. 10 20
      htdocs/barcode/codeinit.php
  50. 1 2
      htdocs/barcode/printsheet.php
  51. 2 4
      htdocs/blockedlog/admin/blockedlog.php
  52. 8 16
      htdocs/blockedlog/admin/blockedlog_list.php
  53. 3 6
      htdocs/blockedlog/ajax/authority.php
  54. 4 8
      htdocs/blockedlog/ajax/block-info.php
  55. 7 14
      htdocs/blockedlog/class/authority.class.php
  56. 43 86
      htdocs/blockedlog/class/blockedlog.class.php
  57. 2 4
      htdocs/bom/bom_agenda.php
  58. 5 10
      htdocs/bom/bom_card.php
  59. 1 2
      htdocs/bom/bom_document.php
  60. 8 16
      htdocs/bom/bom_list.php
  61. 2 4
      htdocs/bom/class/api_boms.class.php
  62. 15 30
      htdocs/bom/class/bom.class.php
  63. 1 2
      htdocs/bom/tpl/objectline_create.tpl.php
  64. 1 2
      htdocs/bookmarks/admin/bookmark.php
  65. 2 4
      htdocs/bookmarks/bookmarks.lib.php
  66. 6 12
      htdocs/bookmarks/card.php
  67. 6 12
      htdocs/bookmarks/class/bookmark.class.php
  68. 4 8
      htdocs/bookmarks/list.php
  69. 3 6
      htdocs/cashdesk/admin/cashdesk.php
  70. 2 4
      htdocs/cashdesk/affContenu.php
  71. 1 2
      htdocs/cashdesk/class/Auth.class.php
  72. 12 24
      htdocs/cashdesk/class/Facturation.class.php
  73. 5 10
      htdocs/cashdesk/facturation.php
  74. 2 4
      htdocs/cashdesk/facturation_dhtml.php
  75. 8 16
      htdocs/cashdesk/facturation_verif.php
  76. 3 6
      htdocs/cashdesk/index.php
  77. 2 4
      htdocs/cashdesk/index_verif.php
  78. 3 6
      htdocs/cashdesk/tpl/facturation1.tpl.php
  79. 1 2
      htdocs/cashdesk/tpl/validation1.tpl.php
  80. 6 12
      htdocs/cashdesk/validation_verif.php
  81. 4 8
      htdocs/categories/admin/categorie.php
  82. 15 30
      htdocs/categories/card.php
  83. 2 4
      htdocs/categories/class/api_categories.class.php
  84. 38 76
      htdocs/categories/class/categorie.class.php
  85. 2 4
      htdocs/categories/edit.php
  86. 2 4
      htdocs/categories/index.php
  87. 3 6
      htdocs/categories/photos.php
  88. 1 2
      htdocs/categories/traduction.php
  89. 31 62
      htdocs/categories/viewcat.php
  90. 3 6
      htdocs/collab/index.php
  91. 24 48
      htdocs/comm/action/card.php
  92. 24 48
      htdocs/comm/action/class/actioncomm.class.php
  93. 5 10
      htdocs/comm/action/class/actioncommreminder.class.php
  94. 1 2
      htdocs/comm/action/class/api_agendaevents.class.php
  95. 3 6
      htdocs/comm/action/class/cactioncomm.class.php
  96. 4 8
      htdocs/comm/action/class/ical.class.php
  97. 2 4
      htdocs/comm/action/document.php
  98. 45 91
      htdocs/comm/action/index.php
  99. 11 22
      htdocs/comm/action/list.php
  100. 15 30
      htdocs/comm/action/pertype.php

+ 2 - 4
dev/examples/code/create_invoice.php

@@ -91,8 +91,7 @@ if ($idobject > 0)
 		$error++;
 		dol_print_error($db, $obj->error);
 	}
-}
-else {
+} else {
 	$error++;
 	dol_print_error($db, $obj->error);
 }
@@ -104,8 +103,7 @@ if (! $error)
 {
 	$db->commit();
 	print '--- end ok'."\n";
-}
-else {
+} else {
 	print '--- end error code='.$error."\n";
 	$db->rollback();
 }

+ 2 - 4
dev/examples/code/create_order.php

@@ -89,8 +89,7 @@ if ($idobject > 0)
 		$error++;
 		dol_print_error($db, $com->error);
 	}
-}
-else {
+} else {
 	$error++;
 	dol_print_error($db, $com->error);
 }
@@ -102,8 +101,7 @@ if (! $error)
 {
 	$db->commit();
 	print '--- end ok'."\n";
-}
-else {
+} else {
 	print '--- end error code='.$error."\n";
 	$db->rollback();
 }

+ 2 - 4
dev/examples/code/create_product.php

@@ -82,8 +82,7 @@ $idobject = $myproduct->create($user);
 if ($idobject > 0)
 {
 	print "OK Object created with id ".$idobject."\n";
-}
-else {
+} else {
 	$error++;
 	dol_print_error($db, $myproduct->error);
 }
@@ -94,8 +93,7 @@ if (! $error)
 {
 	$db->commit();
 	print '--- end ok'."\n";
-}
-else {
+} else {
 	print '--- end error code='.$error."\n";
 	$db->rollback();
 }

+ 3 - 6
dev/examples/code/create_user.php

@@ -78,12 +78,10 @@ if ($idobject > 0)
 		$error++;
 		dol_print_error($db, $obj->error);
 	}
-}
-elseif ($obj->error == 'ErrorLoginAlreadyExists')
+} elseif ($obj->error == 'ErrorLoginAlreadyExists')
 {
      print "User with login ".$obj->login." already exists\n";
-}
-else {
+} else {
 	$error++;
 	dol_print_error($db, $obj->error);
 }
@@ -95,8 +93,7 @@ if (! $error)
 {
 	$db->commit();
 	print '--- end ok'."\n";
-}
-else {
+} else {
 	print '--- end error code='.$error."\n";
 	$db->rollback();
 }

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

@@ -119,8 +119,7 @@ if (empty($reshook))
 			{
 				$obj = $db->fetch_object($resql);
 				$country_code = $obj->code;
-			}
-			else dol_print_error($db);
+			} else dol_print_error($db);
 
 			// Try to load sql file
 			if ($country_code)
@@ -143,8 +142,7 @@ if (empty($reshook))
 				if ($result > 0)
 				{
 					setEventMessages($langs->trans("ChartLoaded"), null, 'mesgs');
-				}
-				else {
+				} else {
 					setEventMessages($langs->trans("ErrorDuringChartLoad"), null, 'warnings');
 				}
 			}
@@ -234,8 +232,7 @@ if (strlen(trim($search_account))) {
 			}
 			$sql .= " AND (aa.account_number LIKE '".$startchar.$search_account_tmp_clean."'";
 			$sql .= " OR aa.account_number LIKE '".$startchar.$search_account_clean."%')";
-		}
-		else $sql .= natural_search("aa.account_number", $search_account_tmp);
+		} else $sql .= natural_search("aa.account_number", $search_account_tmp);
 	}
 }
 if (strlen(trim($search_label)))			$sql .= natural_search("aa.label", $search_label);
@@ -327,8 +324,7 @@ if ($resql)
 
             $i++;
         }
-    }
-    else dol_print_error($db);
+    } 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")).'">';
@@ -430,8 +426,7 @@ if ($resql)
 				print $accountparent->getNomUrl(1);
 				print "</td>\n";
 				if (!$i) $totalarray['nbfield']++;
-			}
-			else {
+			} else {
 				print '<td>&nbsp;</td>';
 				if (!$i) $totalarray['nbfield']++;
 			}

+ 27 - 54
htdocs/accountancy/admin/accountmodel.php

@@ -228,8 +228,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
 		{
 			if ($value == 'price' || preg_match('/^amount/i', $value) || $value == 'taux') {
 				$_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]], 'MU');
-			}
-			elseif ($value == 'entity') {
+			} elseif ($value == 'entity') {
 				$_POST[$listfieldvalue[$i]] = $conf->entity;
 			}
 			if ($i) $sql .= ",";
@@ -245,12 +244,10 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
 		{
 			setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
 			$_POST = array('id'=>$id); // Clean $_POST array, we keep only
-		}
-		else {
+		} else {
 			if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
 				setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors');
-			}
-			else {
+			} else {
 				dol_print_error($db);
 			}
 		}
@@ -259,8 +256,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
 	// Si verif ok et action modify, on modifie la ligne
 	if ($ok && GETPOST('actionmodify', 'alpha'))
 	{
-		if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
-		else { $rowidcol = "rowid"; }
+		if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
 
 		// Modify entry
 		$sql = "UPDATE ".$tabname[$id]." SET ";
@@ -275,8 +271,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
 		{
 			if ($field == 'price' || preg_match('/^amount/i', $field) || $field == 'taux') {
 				$_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]], 'MU');
-			}
-			elseif ($field == 'entity') {
+			} elseif ($field == 'entity') {
 				$_POST[$listfieldvalue[$i]] = $conf->entity;
 			}
 			if ($i) $sql .= ",";
@@ -305,8 +300,7 @@ if (GETPOST('actioncancel', 'alpha'))
 
 if ($action == 'confirm_delete' && $confirm == 'yes')       // delete
 {
-	if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
-	else { $rowidcol = "rowid"; }
+	if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
 
 	$sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol."='".$rowid."'";
 
@@ -317,8 +311,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes')       // delete
 		if ($db->errno() == 'DB_ERROR_CHILD_EXISTS')
 		{
 			setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors');
-		}
-		else {
+		} else {
 			dol_print_error($db);
 		}
 	}
@@ -327,13 +320,11 @@ if ($action == 'confirm_delete' && $confirm == 'yes')       // delete
 // activate
 if ($action == $acts[0])
 {
-	if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
-	else { $rowidcol = "rowid"; }
+	if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
 
 	if ($rowid) {
 		$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'";
-	}
-	elseif ($code) {
+	} elseif ($code) {
 		$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".$code."'";
 	}
 
@@ -347,13 +338,11 @@ if ($action == $acts[0])
 // disable
 if ($action == $acts[1])
 {
-	if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
-	else { $rowidcol = "rowid"; }
+	if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
 
 	if ($rowid) {
 		$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'";
-	}
-	elseif ($code) {
+	} elseif ($code) {
 		$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".$code."'";
 	}
 
@@ -367,13 +356,11 @@ if ($action == $acts[1])
 // favorite
 if ($action == 'activate_favorite')
 {
-	if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
-	else { $rowidcol = "rowid"; }
+	if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
 
 	if ($rowid) {
 		$sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol."='".$rowid."'";
-	}
-	elseif ($code) {
+	} elseif ($code) {
 		$sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE code='".$code."'";
 	}
 
@@ -387,13 +374,11 @@ if ($action == 'activate_favorite')
 // disable favorite
 if ($action == 'disable_favorite')
 {
-	if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
-	else { $rowidcol = "rowid"; }
+	if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
 
 	if ($rowid) {
 		$sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol."='".$rowid."'";
-	}
-	elseif ($code) {
+	} elseif ($code) {
 		$sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE code='".$code."'";
 	}
 
@@ -579,8 +564,7 @@ if ($id)
 					print '<td class="liste_titre">';
 					print $form->select_country($search_country_id, 'search_country_id', '', 28, 'maxwidth200 maxwidthonsmartphone');
 					print '</td>';
-				}
-				else {
+				} else {
 					print '<td class="liste_titre"></td>';
 				}
 			}
@@ -626,8 +610,7 @@ if ($id)
 
 					print '<td colspan="3" class="right"><a name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).'">&nbsp;</a><input type="submit" class="button" name="actionmodify" value="'.$langs->trans("Modify").'">';
 					print '&nbsp;<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'"></td>';
-				}
-				else {
+				} else {
 				  	$tmpaction = 'view';
 					$parameters = array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
 					$reshook = $hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
@@ -648,25 +631,20 @@ if ($id)
 							if ($value == 'element')
 							{
 								$valuetoshow = isset($elementList[$valuetoshow]) ? $elementList[$valuetoshow] : $valuetoshow;
-							}
-							elseif ($value == 'source')
+							} elseif ($value == 'source')
 							{
 								$valuetoshow = isset($sourceList[$valuetoshow]) ? $sourceList[$valuetoshow] : $valuetoshow;
-							}
-							elseif ($valuetoshow == 'all') {
+							} elseif ($valuetoshow == 'all') {
 								$valuetoshow = $langs->trans('All');
-							}
-							elseif ($fieldlist[$field] == 'country') {
+							} elseif ($fieldlist[$field] == 'country') {
 								if (empty($obj->country_code))
 								{
 									$valuetoshow = '-';
-								}
-								else {
+								} else {
 									$key = $langs->trans("Country".strtoupper($obj->country_code));
 									$valuetoshow = ($key != "Country".strtoupper($obj->country_code) ? $obj->country_code." - ".$key : $obj->country);
 								}
-							}
-							elseif ($fieldlist[$field] == 'country_id') {
+							} elseif ($fieldlist[$field] == 'country_id') {
 								$showfield = 0;
 							}
 
@@ -703,8 +681,7 @@ if ($id)
 				$i++;
 			}
 		}
-	}
-	else {
+	} else {
 		dol_print_error($db);
 	}
 
@@ -756,8 +733,7 @@ function fieldListAccountModel($fieldlist, $obj = '', $tabname = '', $context =
 			$fieldname = 'country';
 			print $form->select_country((!empty($obj->country_code) ? $obj->country_code : (!empty($obj->country) ? $obj->country : '')), $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone');
 			print '</td>';
-		}
-		elseif ($fieldlist[$field] == 'country_id')
+		} elseif ($fieldlist[$field] == 'country_id')
 		{
 			if (!in_array('country', $fieldlist))	// If there is already a field country, we don't show country_id (avoid duplicate)
 			{
@@ -766,8 +742,7 @@ function fieldListAccountModel($fieldlist, $obj = '', $tabname = '', $context =
 				print '<input type="hidden" name="'.$fieldlist[$field].'" value="'.$country_id.'">';
 				print '</td>';
 			}
-		}
-		elseif ($fieldlist[$field] == 'type_cdr') {
+		} elseif ($fieldlist[$field] == 'type_cdr') {
 			if ($fieldlist[$field] == 'type_cdr') print '<td class="center">';
 			else print '<td>';
 			if ($fieldlist[$field] == 'type_cdr') {
@@ -776,11 +751,9 @@ function fieldListAccountModel($fieldlist, $obj = '', $tabname = '', $context =
 				print $form->selectyesno($fieldlist[$field], (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''), 1);
 			}
 			print '</td>';
-		}
-		elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) {
+		} elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) {
 			print '<td><input type="text" class="flat" value="'.(!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'').'" size="10" name="'.$fieldlist[$field].'"></td>';
-		}
-		else {
+		} else {
 			print '<td>';
 			$size = ''; $class = '';
 			if ($fieldlist[$field] == 'code') $size = 'size="8" ';

+ 7 - 14
htdocs/accountancy/admin/card.php

@@ -75,16 +75,14 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount)
 		if ($conf->global->ACCOUNTING_MANAGE_ZERO == 1)
 		{
 			$account_number = GETPOST('account_number', 'string');
-		}
-		else {
+		} else {
 			$account_number = clean_account(GETPOST('account_number', 'string'));
 		}
 
 		if (GETPOST('account_parent', 'int') <= 0)
 		{
 			$account_parent = 0;
-		}
-		else {
+		} else {
 			$account_parent = GETPOST('account_parent', 'int');
 		}
 
@@ -102,13 +100,11 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount)
 			$error = 1;
 			$action = "create";
 			setEventMessages($object->error, $object->errors, 'errors');
-		}
-		elseif ($res == - 4) {
+		} elseif ($res == - 4) {
 			$error = 2;
 			$action = "create";
 			setEventMessages($object->error, $object->errors, 'errors');
-		}
-		elseif ($res < 0)
+		} elseif ($res < 0)
 		{
 		    $error++;
 		    setEventMessages($object->error, $object->errors, 'errors');
@@ -138,16 +134,14 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount)
 		if ($conf->global->ACCOUNTING_MANAGE_ZERO == 1)
 		{
 			$account_number = GETPOST('account_number', 'string');
-		}
-		else {
+		} else {
 			$account_number = clean_account(GETPOST('account_number', 'string'));
 		}
 
 		if (GETPOST('account_parent', 'int') <= 0)
 		{
 			$account_parent = 0;
-		}
-		else {
+		} else {
 			$account_parent = GETPOST('account_parent', 'int');
 		}
 
@@ -265,8 +259,7 @@ if ($action == 'create') {
 	print '</div>';
 
 	print '</form>';
-}
-elseif ($id > 0 || $ref) {
+} elseif ($id > 0 || $ref) {
 	$result = $object->fetch($id, $ref, 1);
 
 	if ($result > 0) {

+ 30 - 60
htdocs/accountancy/admin/categories_list.php

@@ -235,12 +235,10 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
         {
             setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
         	$_POST = array('id'=>$id); // Clean $_POST array, we keep only
-        }
-        else {
+        } else {
             if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
                 setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors');
-            }
-            else {
+            } else {
                 dol_print_error($db);
             }
         }
@@ -249,8 +247,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
     // Si verif ok et action modify, on modifie la ligne
     if ($ok && GETPOST('actionmodify', 'alpha'))
     {
-        if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
-        else { $rowidcol = "rowid"; }
+        if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
 
         // Modify entry
         $sql = "UPDATE ".$tabname[$id]." SET ";
@@ -265,8 +262,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
         {
             if ($field == 'fk_country' && $_POST['country'] > 0) {
             	$_POST[$listfieldvalue[$i]] = $_POST['country'];
-            }
-            elseif ($field == 'entity') {
+            } elseif ($field == 'entity') {
             	$_POST[$listfieldvalue[$i]] = $conf->entity;
             }
             if ($i) $sql .= ",";
@@ -295,8 +291,7 @@ if (GETPOST('actioncancel', 'alpha'))
 
 if ($action == 'confirm_delete' && $confirm == 'yes')       // delete
 {
-    if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
-    else { $rowidcol = "rowid"; }
+    if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
 
     $sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol." = '".$db->escape($rowid)."'";
 
@@ -307,8 +302,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes')       // delete
         if ($db->errno() == 'DB_ERROR_CHILD_EXISTS')
         {
             setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors');
-        }
-        else {
+        } else {
             dol_print_error($db);
         }
     }
@@ -317,13 +311,11 @@ if ($action == 'confirm_delete' && $confirm == 'yes')       // delete
 // activate
 if ($action == $acts[0])
 {
-    if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
-    else { $rowidcol = "rowid"; }
+    if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
 
     if ($rowid) {
         $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol." = '".$db->escape($rowid)."'";
-    }
-    elseif ($code) {
+    } elseif ($code) {
     	$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code = '".$db->escape($code)."'";
     }
 
@@ -337,13 +329,11 @@ if ($action == $acts[0])
 // disable
 if ($action == $acts[1])
 {
-    if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
-    else { $rowidcol = "rowid"; }
+    if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
 
     if ($rowid) {
     	$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol." = '".$db->escape($rowid)."'";
-    }
-    elseif ($code) {
+    } elseif ($code) {
     	$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code = '".$db->escape($code)."'";
     }
 
@@ -357,13 +347,11 @@ if ($action == $acts[1])
 // favorite
 if ($action == 'activate_favorite')
 {
-    if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
-    else { $rowidcol = "rowid"; }
+    if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
 
     if ($rowid) {
     	$sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol." = '".$db->escape($rowid)."'";
-    }
-    elseif ($code) {
+    } elseif ($code) {
     	$sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE code = '".$db->escape($code)."'";
     }
 
@@ -377,13 +365,11 @@ if ($action == 'activate_favorite')
 // disable favorite
 if ($action == 'disable_favorite')
 {
-    if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
-    else { $rowidcol = "rowid"; }
+    if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
 
     if ($rowid) {
     	$sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol." = '".$db->escape($rowid)."'";
-    }
-    elseif ($code) {
+    } elseif ($code) {
     	$sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE code = '".$db->escape($code)."'";
     }
 
@@ -595,8 +581,7 @@ if ($id)
                     print $form->select_country($search_country_id, 'search_country_id', '', 28, 'maxwidth200 maxwidthonsmartphone');
                     print '</td>';
                     $filterfound++;
-                }
-                else {
+                } else {
                     print '<td class="liste_titre"></td>';
                 }
             }
@@ -723,8 +708,7 @@ if ($id)
                     print '<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'">';
                     print '</td>';
                     print '<td></td>';
-                }
-                else {
+                } else {
                     $tmpaction = 'view';
                     $parameters = array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
                     $reshook = $hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
@@ -741,34 +725,27 @@ if ($id)
                             if ($value == 'category_type')
                             {
                                 $valuetoshow = yn($valuetoshow);
-                            }
-                            elseif ($valuetoshow == 'all') {
+                            } elseif ($valuetoshow == 'all') {
                                 $valuetoshow = $langs->trans('All');
-                            }
-                            elseif ($fieldlist[$field] == 'country') {
+                            } elseif ($fieldlist[$field] == 'country') {
                                 if (empty($obj->country_code))
                                 {
                                     $valuetoshow = '-';
-                                }
-                                else {
+                                } else {
                                     $key = $langs->trans("Country".strtoupper($obj->country_code));
                                     $valuetoshow = ($key != "Country".strtoupper($obj->country_code) ? $obj->country_code." - ".$key : $obj->country);
                                 }
-                            }
-                            elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_country') {
+                            } elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_country') {
                                 $key = $langs->trans("Country".strtoupper($obj->code));
                                 $valuetoshow = ($obj->code && $key != "Country".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]});
-                            }
-                            elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_availability') {
+                            } elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_availability') {
                                 $langs->loadLangs(array("propal"));
                                 $key = $langs->trans("AvailabilityType".strtoupper($obj->code));
                                 $valuetoshow = ($obj->code && $key != "AvailabilityType".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]});
-                            }
-                            elseif ($fieldlist[$field] == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_actioncomm') {
+                            } elseif ($fieldlist[$field] == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_actioncomm') {
                                 $key = $langs->trans("Action".strtoupper($obj->code));
                                 $valuetoshow = ($obj->code && $key != "Action".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]});
-                            }
-                            elseif ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') {
+                            } elseif ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') {
                                 $showfield = 0;
                             }
 
@@ -810,8 +787,7 @@ if ($id)
                         if ($user->admin) print '<a href="'.$url.'action=delete">'.img_delete().'</a>';
                         //else print '<a href="#">'.img_delete().'</a>';    // Some dictionary can be edited by other profile than admin
                         print '</td>';
-                    }
-                    else print '<td>&nbsp;</td>';
+                    } else print '<td>&nbsp;</td>';
 
                     // Link to setup the group
                     print '<td class="center">';
@@ -827,8 +803,7 @@ if ($id)
                 $i++;
             }
         }
-    }
-    else {
+    } else {
         dol_print_error($db);
     }
 
@@ -876,13 +851,11 @@ function fieldListAccountingCategories($fieldlist, $obj = '', $tabname = '', $co
 			{
 				$fieldname = 'country_id';
 				print $form->select_country(GETPOST('country_id', 'int'), $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone');
-			}
-			else {
+			} else {
 				print $form->select_country((!empty($obj->country_code) ? $obj->country_code : (!empty($obj->country) ? $obj->country : $mysoc->country_code)), $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone');
 			}
 			print '</td>';
-		}
-		elseif ($fieldlist[$field] == 'country_id')
+		} elseif ($fieldlist[$field] == 'country_id')
 		{
 			if (!in_array('country', $fieldlist))	// If there is already a field country, we don't show country_id (avoid duplicate)
 			{
@@ -891,16 +864,13 @@ function fieldListAccountingCategories($fieldlist, $obj = '', $tabname = '', $co
 				print '<input type="hidden" name="'.$fieldlist[$field].'" value="'.$country_id.'">';
 				print '</td>';
 			}
-		}
-		elseif ($fieldlist[$field] == 'category_type') {
+		} elseif ($fieldlist[$field] == 'category_type') {
 		    print '<td>';
 			print $form->selectyesno($fieldlist[$field], (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''), 1);
 			print '</td>';
-		}
-		elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) {
+		} elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) {
 			print '<td><input type="text" class="flat minwidth100" value="'.(!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'"></td>';
-		}
-		else {
+		} else {
 			print '<td>';
 			$size = ''; $class = '';
 			if ($fieldlist[$field] == 'code') $class = 'maxwidth100';

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

@@ -193,8 +193,7 @@ foreach ($list_account as $key) {
 	$reg = array();
 	if (preg_match('/---(.*)---/', $key, $reg)) {
 		print '<tr class="liste_titre"><td>'.$langs->trans($reg[1]).'</td><td></td></tr>';
-	}
-	else {
+	} else {
 		print '<tr class="oddeven value">';
 		// Param
 		$label = $langs->trans($key);

+ 1 - 3
htdocs/accountancy/admin/fiscalyear_card.php

@@ -71,9 +71,7 @@ if ($action == 'confirm_delete' && $confirm == "yes") {
 	} else {
 		setEventMessages($object->error, $object->errors, 'errors');
 	}
-}
-
-elseif ($action == 'add') {
+} elseif ($action == 'add') {
 	if (!GETPOST('cancel', 'alpha')) {
 		$error = 0;
 

+ 17 - 34
htdocs/accountancy/admin/journals_list.php

@@ -238,12 +238,10 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
 		{
 			setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
 			$_POST = array('id'=>$id); // Clean $_POST array, we keep only
-		}
-		else {
+		} else {
 			if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
 				setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors');
-			}
-			else {
+			} else {
 				dol_print_error($db);
 			}
 		}
@@ -252,8 +250,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
 	// Si verif ok et action modify, on modifie la ligne
 	if ($ok && GETPOST('actionmodify', 'alpha'))
 	{
-		if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
-		else { $rowidcol = "rowid"; }
+		if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
 
 		// Modify entry
 		$sql = "UPDATE ".$tabname[$id]." SET ";
@@ -268,8 +265,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
 		{
 			if ($field == 'price' || preg_match('/^amount/i', $field) || $field == 'taux') {
 				$_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]], 'MU');
-			}
-			elseif ($field == 'entity') {
+			} elseif ($field == 'entity') {
 				$_POST[$listfieldvalue[$i]] = $conf->entity;
 			}
 			if ($i) $sql .= ",";
@@ -299,8 +295,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
 
 if ($action == 'confirm_delete' && $confirm == 'yes')       // delete
 {
-	if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
-	else { $rowidcol = "rowid"; }
+	if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
 
 	$sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol."='".$rowid."'";
 	$sql .= " AND entity = ".$conf->entity;
@@ -312,8 +307,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes')       // delete
 		if ($db->errno() == 'DB_ERROR_CHILD_EXISTS')
 		{
 			setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors');
-		}
-		else {
+		} else {
 			dol_print_error($db);
 		}
 	}
@@ -322,13 +316,11 @@ if ($action == 'confirm_delete' && $confirm == 'yes')       // delete
 // activate
 if ($action == $acts[0])
 {
-	if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
-	else { $rowidcol = "rowid"; }
+	if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
 
 	if ($rowid) {
 		$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'";
-	}
-	elseif ($code) {
+	} elseif ($code) {
 		$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".$code."'";
 	}
 	$sql .= " AND entity = ".$conf->entity;
@@ -343,13 +335,11 @@ if ($action == $acts[0])
 // disable
 if ($action == $acts[1])
 {
-	if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
-	else { $rowidcol = "rowid"; }
+	if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
 
 	if ($rowid) {
 		$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'";
-	}
-	elseif ($code) {
+	} elseif ($code) {
 		$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".$code."'";
 	}
 	$sql .= " AND entity = ".$conf->entity;
@@ -593,8 +583,7 @@ if ($id)
 					print '<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'">';
 					print '<div name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).'"></div>';
 					print '</td>';
-				}
-				else {
+				} else {
 				  	$tmpaction = 'view';
 					$parameters = array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
 					$reshook = $hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
@@ -611,12 +600,10 @@ if ($id)
 							$valuetoshow = $obj->{$fieldlist[$field]};
 							if ($valuetoshow == 'all') {
 								$valuetoshow = $langs->trans('All');
-							}
-							elseif ($fieldlist[$field] == 'nature' && $tabname[$id] == MAIN_DB_PREFIX.'accounting_journal') {
+							} elseif ($fieldlist[$field] == 'nature' && $tabname[$id] == MAIN_DB_PREFIX.'accounting_journal') {
 								$key = $langs->trans("AccountingJournalType".strtoupper($obj->nature));
 								$valuetoshow = ($obj->nature && $key != "AccountingJournalType".strtoupper($langs->trans($obj->nature)) ? $key : $obj->{$fieldlist[$field]});
-							}
-							elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'accounting_journal') {
+							} elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'accounting_journal') {
 								$valuetoshow = $langs->trans($obj->label);
                             }
 
@@ -664,8 +651,7 @@ if ($id)
 						if ($user->admin) print '<a href="'.$url.'action=delete">'.img_delete().'</a>';
 						//else print '<a href="#">'.img_delete().'</a>';    // Some dictionary can be edited by other profile than admin
 						print '</td>';
-					}
-					else print '<td>&nbsp;</td>';
+					} else print '<td>&nbsp;</td>';
 
 					print '<td></td>';
 
@@ -676,8 +662,7 @@ if ($id)
 				$i++;
 			}
 		}
-	}
-	else {
+	} else {
 		dol_print_error($db);
 	}
 
@@ -721,11 +706,9 @@ function fieldListJournal($fieldlist, $obj = '', $tabname = '', $context = '')
 			print '<td>';
 			print $form->selectarray('nature', $sourceList, (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''));
 			print '</td>';
-		}
-		elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) {
+		} elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) {
 			print '<td><input type="text" class="flat minwidth100" value="'.(!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'"></td>';
-		}
-		else {
+		} else {
 			print '<td>';
 			$size = ''; $class = '';
 			if ($fieldlist[$field] == 'code')  $class = 'maxwidth100';

+ 22 - 42
htdocs/accountancy/admin/productaccount.php

@@ -252,20 +252,16 @@ $sql .= " FROM ".MAIN_DB_PREFIX."product as p";
 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON";
 if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
     $sql .= " p.accountancy_code_buy = aa.account_number AND aa.fk_pcg_version = '".$pcgvercode."'";
-}
-elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA')
+} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA')
 {
 	$sql .= " p.accountancy_code_buy_intra = aa.account_number AND aa.fk_pcg_version = '".$pcgvercode."'";
-}
-elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT')
+} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT')
 {
 	$sql .= " p.accountancy_code_buy_export = aa.account_number AND aa.fk_pcg_version = '".$pcgvercode."'";
-}
-elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL')
+} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL')
 {
     $sql .= " p.accountancy_code_sell = aa.account_number AND aa.fk_pcg_version = '".$pcgvercode."'";
-}
-elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA')
+} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA')
 {
     $sql .= " p.accountancy_code_sell_intra = aa.account_number AND aa.fk_pcg_version = '".$pcgvercode."'";
 } else {
@@ -288,13 +284,11 @@ if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
     if (strlen(trim($search_current_account))) {
         $sql .= natural_search("p.accountancy_code_sell", $search_current_account);
     }
-}
-elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
+} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
     if (strlen(trim($search_current_account))) {
         $sql .= natural_search("p.accountancy_code_sell_intra", $search_current_account);
     }
-}
-else {
+} else {
     if (strlen(trim($search_current_account))) {
         $sql .= natural_search("p.accountancy_code_sell_export", $search_current_account);
     }
@@ -490,34 +484,27 @@ if ($result)
 			if ($accounting_product_mode == 'ACCOUNTANCY_SELL') {
 				$compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
 				$compta_prodsell_id = $aarowid_prodsell;
-			}
-			elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
+			} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
 	            $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef"));
     	        $compta_prodsell_id = $aarowid_prodsell_intra;
-			}
-        	elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') {
+			} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') {
             	$compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef"));
             	$compta_prodsell_id = $aarowid_prodsell_export;
-        	}
-        	else {
+        	} else {
 				$compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
 				$compta_prodsell_id = $aarowid_prodsell;
 			}
-		}
-		else {
+		} else {
 			if ($accounting_product_mode == 'ACCOUNTANCY_SELL') {
 				$compta_prodsell = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
 				$compta_prodsell_id = $aarowid_servsell;
-			}
-			elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
+			} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
 				$compta_prodsell = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef"));
 				$compta_prodsell_id = $aarowid_servsell_intra;
-			}
-			elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') {
+			} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') {
 				$compta_prodsell = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef"));
 				$compta_prodsell_id = $aarowid_servsell_export;
-			}
-			else {
+			} else {
 				$compta_prodsell = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
 				$compta_prodsell_id = $aarowid_servsell;
 			}
@@ -528,34 +515,27 @@ if ($result)
 			if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
 				$compta_prodbuy = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
 				$compta_prodbuy_id = $aarowid_prodbuy;
-			}
-			elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') {
+			} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') {
 				$compta_prodbuy = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT : $langs->trans("CodeNotDef"));
 				$compta_prodbuy_id = $aarowid_prodbuy_intra;
-			}
-			elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') {
+			} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') {
 				$compta_prodbuy = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT : $langs->trans("CodeNotDef"));
 				$compta_prodbuy_id = $aarowid_prodbuy_export;
-			}
-			else {
+			} else {
 				$compta_prodbuy = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
 				$compta_prodbuy_id = $aarowid_prodbuy;
 			}
-		}
-		else {
+		} else {
 			if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
 				$compta_prodbuy = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
 				$compta_prodbuy_id = $aarowid_servbuy;
-			}
-			elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') {
+			} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') {
 				$compta_prodbuy = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT : $langs->trans("CodeNotDef"));
 				$compta_prodbuy_id = $aarowid_servbuy_intra;
-			}
-			elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') {
+			} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') {
 				$compta_prodbuy = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT : $langs->trans("CodeNotDef"));
 				$compta_prodbuy_id = $aarowid_servbuy_export;
-			}
-			else {
+			} else {
 				$compta_prodbuy = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
 				$compta_prodbuy_id = $aarowid_servbuy;
 			}
@@ -618,7 +598,7 @@ if ($result)
 			if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid
 			print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1);
 			print '</td>';
-		}  elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') {
+		} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') {
 			// Accounting account buy intra (In EEC)
 			print '<td class="left">';
 			//$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha');        This is id and we need a code
@@ -628,7 +608,7 @@ if ($result)
 			if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid
 			print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1);
 			print '</td>';
-		}  elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') {
+		} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') {
 			// Accounting account buy export (Out of EEC)
 			print '<td class="left">';
 			//$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha');        This is id and we need a code

+ 6 - 15
htdocs/accountancy/bookkeeping/card.php

@@ -138,9 +138,7 @@ if ($action == "confirm_update") {
 			}
 		}
 	}
-}
-
-elseif ($action == "add") {
+} elseif ($action == "add") {
 	$error = 0;
 
 	if ((floatval($debit) != 0.0) && (floatval($credit) != 0.0))
@@ -199,9 +197,7 @@ elseif ($action == "add") {
 			$action = '';
 		}
 	}
-}
-
-elseif ($action == "confirm_delete") {
+} elseif ($action == "confirm_delete") {
 	$object = new BookKeeping($db);
 
 	$result = $object->fetch($id, null, $mode);
@@ -216,9 +212,7 @@ elseif ($action == "confirm_delete") {
 		}
 	}
 	$action = '';
-}
-
-elseif ($action == "confirm_create") {
+} elseif ($action == "confirm_create") {
 	$error = 0;
 
 	$object = new BookKeeping($db);
@@ -628,8 +622,7 @@ if ($action == 'create')
 						if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX))
 						{
 							print $formaccounting->select_auxaccount((GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account), 'subledger_account', 1);
-						}
-						else {
+						} else {
 							print '<input type="text" class="maxwidth150" name="subledger_account" value="'.(GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account).'">';
 						}
 						print '</td>';
@@ -684,8 +677,7 @@ if ($action == 'create')
 					if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX))
 					{
 						print $formaccounting->select_auxaccount('', 'subledger_account', 1);
-					}
-					else {
+					} else {
 						print '<input type="text" class="maxwidth150" name="subledger_account" value="">';
 					}
 					print '</td>';
@@ -705,8 +697,7 @@ if ($action == 'create')
 					if ($total_debit == $total_credit)
 					{
 						print '<a class="button" href="'.$_SERVER["PHP_SELF"].'?piece_num='.$object->piece_num.'&action=valid">'.$langs->trans("ValidTransaction").'</a>';
-					}
-					else {
+					} else {
 						print '<input type="submit" class="button" disabled="disabled" href="#" title="'.dol_escape_htmltag($langs->trans("MvtNotCorrectlyBalanced", $debit, $credit)).'" value="'.dol_escape_htmltag($langs->trans("ValidTransaction")).'">';
 					}
 

+ 12 - 24
htdocs/accountancy/bookkeeping/list.php

@@ -351,16 +351,14 @@ if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouveme
 		$result = $object->deleteByYearAndJournal($delyear, $deljournal, '', ($delmonth > 0 ? $delmonth : 0));
 		if ($result < 0) {
 			setEventMessages($object->error, $object->errors, 'errors');
-		}
-		else {
+		} else {
 			setEventMessages("RecordDeleted", null, 'mesgs');
 		}
 
 		// Make a redirect to avoid to launch the delete later after a back button
 		header("Location: list.php".($param ? '?'.$param : ''));
 		exit;
-	}
-	else {
+	} else {
 		setEventMessages("NoRecordDeleted", null, 'warnings');
 	}
 }
@@ -371,8 +369,7 @@ if ($action == 'delmouvconfirm' && $user->rights->accounting->mouvements->suppri
 		$result = $object->deleteMvtNum($mvt_num);
 		if ($result < 0) {
 			setEventMessages($object->error, $object->errors, 'errors');
-		}
-		else {
+		} else {
 			setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
 		}
 
@@ -477,8 +474,7 @@ if ($action == 'export_file' && $user->rights->accounting->mouvements->export) {
 	if ($result < 0)
 	{
 		setEventMessages($object->error, $object->errors, 'errors');
-	}
-	else {
+	} else {
 	    // Export files
 		$accountancyexport = new AccountancyExport($db);
 		$accountancyexport->export($object->lines, $formatexportset);
@@ -486,8 +482,7 @@ if ($action == 'export_file' && $user->rights->accounting->mouvements->export) {
         if (!empty($accountancyexport->errors))
         {
             setEventMessages('', $accountancyexport->errors, 'errors');
-        }
-        else {
+        } else {
             // Specify as export : update field date_export
             $error = 0;
             $db->begin();
@@ -516,8 +511,7 @@ if ($action == 'export_file' && $user->rights->accounting->mouvements->export) {
             {
             	$db->commit();
             	// setEventMessages($langs->trans("AllExportedMovementsWereRecordedAsExported"), null, 'mesgs');
-            }
-            else {
+            } else {
             	$error++;
             	$db->rollback();
             	setEventMessages($langs->trans("NotAllExportedMovementsCouldBeRecordedAsExported"), null, 'errors');
@@ -553,8 +547,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords)
 {
 	$num = $nbtotalofrecords;
-}
-else {
+} else {
 	$sql .= $db->plimit($limit + 1, $offset);
 
 	$resql = $db->query($sql);
@@ -714,8 +707,7 @@ if (!empty($arrayfields['t.subledger_account']['checked']))
 	if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX))
 	{
 		print $formaccounting->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', 1);
-	}
-	else {
+	} else {
 		print '<input type="text" class="maxwidth100" name="search_accountancy_aux_code_start" value="'.$search_accountancy_aux_code_start.'">';
 	}
 	print '</div>';
@@ -726,8 +718,7 @@ if (!empty($arrayfields['t.subledger_account']['checked']))
 	if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX))
 	{
 		print $formaccounting->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1);
-	}
-	else {
+	} else {
 		print '<input type="text" class="maxwidth100" name="search_accountancy_aux_code_end" value="'.$search_accountancy_aux_code_end.'">';
 	}
 	print '</div>';
@@ -920,8 +911,7 @@ while ($i < min($num, $limit))
             $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($line->doc_ref);
             $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id;
             $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
-        }
-        elseif ($line->doc_type == 'supplier_invoice')
+        } elseif ($line->doc_type == 'supplier_invoice')
         {
             $langs->loadLangs(array('bills'));
 
@@ -934,8 +924,7 @@ while ($i < min($num, $limit))
             $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
             $subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
             $documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir);
-        }
-        elseif ($line->doc_type == 'expense_report')
+        } elseif ($line->doc_type == 'expense_report')
         {
             $langs->loadLangs(array('trips'));
 
@@ -948,8 +937,7 @@ while ($i < min($num, $limit))
             $filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref);
             $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id;
             $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
-        }
-        else {
+        } else {
             // Other type
         }
 

+ 8 - 16
htdocs/accountancy/bookkeeping/listbyaccount.php

@@ -254,16 +254,14 @@ if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouveme
 		$result = $object->deleteByYearAndJournal($delyear, $deljournal, '', ($delmonth > 0 ? $delmonth : 0));
 		if ($result < 0) {
 			setEventMessages($object->error, $object->errors, 'errors');
-		}
-		else {
+		} else {
 			setEventMessages("RecordDeleted", null, 'mesgs');
 		}
 
 		// Make a redirect to avoid to launch the delete later after a back button
 		header("Location: listbyaccount.php".($param ? '?'.$param : ''));
 		exit;
-	}
-	else {
+	} else {
 		setEventMessages("NoRecordDeleted", null, 'warnings');
 	}
 }
@@ -274,8 +272,7 @@ if ($action == 'delmouvconfirm' && $user->rights->accounting->mouvements->suppri
 		$result = $object->deleteMvtNum($mvt_num);
 		if ($result < 0) {
 			setEventMessages($object->error, $object->errors, 'errors');
-		}
-		else {
+		} else {
 			setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
 		}
 
@@ -534,8 +531,7 @@ while ($i < min($num, $limit))
 				print price($sous_total_debit - $sous_total_credit);
 				print '</td>';
 				print '<td></td>';
-			}
-			else {
+			} else {
 				print '<td></td>';
 				print '<td class="nowraponall right">';
 				print price($sous_total_credit - $sous_total_debit);
@@ -607,8 +603,7 @@ while ($i < min($num, $limit))
 			$filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($line->doc_ref);
 			$urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id;
 			$documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
-		}
-		elseif ($line->doc_type == 'supplier_invoice')
+		} elseif ($line->doc_type == 'supplier_invoice')
 		{
 			$langs->loadLangs(array('bills'));
 
@@ -621,8 +616,7 @@ while ($i < min($num, $limit))
 			$filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
 			$subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
 			$documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir);
-		}
-		elseif ($line->doc_type == 'expense_report')
+		} elseif ($line->doc_type == 'expense_report')
 		{
 			$langs->loadLangs(array('trips'));
 
@@ -635,8 +629,7 @@ while ($i < min($num, $limit))
 			$filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref);
 			$urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id;
 			$documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
-		}
-		else {
+		} else {
 			// Other type
 		}
 
@@ -737,8 +730,7 @@ if ($balance > 0 )
 	print price($sous_total_debit - $sous_total_credit);
 	print '</td>';
 	print '<td></td>';
-}
-else {
+} else {
 	print '<td></td>';
 	print '<td class="nowraponall right">';
 	print price($sous_total_credit - $sous_total_debit);

+ 6 - 12
htdocs/accountancy/class/accountancycategory.class.php

@@ -209,8 +209,7 @@ class AccountancyCategory // extends CommonObject
 			}
 			$this->db->rollback();
 			return -1 * $error;
-		}
-		else {
+		} else {
 			$this->db->commit();
 			return $this->id;
 		}
@@ -268,8 +267,7 @@ class AccountancyCategory // extends CommonObject
 			$this->db->free($resql);
 
 			return 1;
-		}
-		else {
+		} else {
 			$this->error = "Error ".$this->db->lasterror();
 			return -1;
 		}
@@ -332,8 +330,7 @@ class AccountancyCategory // extends CommonObject
 			}
 			$this->db->rollback();
 			return -1 * $error;
-		}
-		else {
+		} else {
 			$this->db->commit();
 			return 1;
 		}
@@ -371,8 +368,7 @@ class AccountancyCategory // extends CommonObject
 			}
 			$this->db->rollback();
 			return -1 * $error;
-		}
-		else {
+		} else {
 			$this->db->commit();
 			return 1;
 		}
@@ -704,8 +700,7 @@ class AccountancyCategory // extends CommonObject
 				$listofaccount .= "'".$cptcursor."'";
 			}
 			$sql .= " AND t.numero_compte IN (".$listofaccount.")";
-		}
-		else {
+		} else {
 			$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
@@ -827,8 +822,7 @@ class AccountancyCategory // extends CommonObject
 			$sql .= " WHERE t.fk_accounting_category = ".$cat_id;
 			$sql .= " AND t.entity = ".$conf->entity;
 			$sql .= " ORDER BY t.account_number";
-		}
-		else {
+		} else {
 			$sql = "SELECT t.rowid, t.account_number, t.label as account_label";
 			$sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t";
 			$sql .= " WHERE ".$predefinedgroupwhere;

+ 9 - 17
htdocs/accountancy/class/accountancyexport.class.php

@@ -362,7 +362,7 @@ class AccountancyExport
 			if ($line->sens == 'D') {
 				print price($line->montant).$separator;
 				print ''.$separator;
-			}elseif ($line->sens == 'C') {
+			} elseif ($line->sens == 'C') {
 				print ''.$separator;
 				print price($line->montant).$separator;
 			}
@@ -602,8 +602,7 @@ class AccountancyExport
 				$Tab['montant_debit']  =  str_pad(number_format(abs($data->montant), 2, ',', ''), 13, ' ', STR_PAD_LEFT);
 
 				$Tab['montant_crebit'] = str_pad(number_format(0, 2, ',', ''), 13, ' ', STR_PAD_LEFT);
-			}
-			else {
+			} else {
 				$Tab['montant_debit']  = str_pad(number_format(0, 2, ',', ''), 13, ' ', STR_PAD_LEFT);
 
 				$Tab['montant_crebit'] = str_pad(number_format(abs($data->montant), 2, ',', ''), 13, ' ', STR_PAD_LEFT);
@@ -899,12 +898,10 @@ class AccountancyExport
             if ($aIndex - 2 >= 0 && $objectLines[$aIndex - 2]->piece_num == $line->piece_num)
             {
                 $sammelBuchung = true;
-            }
-            elseif ($aIndex + 2 < $aSize && $objectLines[$aIndex + 2]->piece_num == $line->piece_num)
+            } elseif ($aIndex + 2 < $aSize && $objectLines[$aIndex + 2]->piece_num == $line->piece_num)
             {
                 $sammelBuchung = true;
-            }
-            elseif ($aIndex + 1 < $aSize
+            } elseif ($aIndex + 1 < $aSize
                     && $objectLines[$aIndex + 1]->piece_num == $line->piece_num
                     && $aIndex - 1 < $aSize
                     && $objectLines[$aIndex - 1]->piece_num == $line->piece_num
@@ -926,8 +923,7 @@ class AccountancyExport
             if ($line->sens == 'D')
             {
                 print 'S'.$this->separator;
-            }
-            else {
+            } else {
                 print 'H'.$this->separator;
             }
             //Grp
@@ -938,12 +934,10 @@ class AccountancyExport
                 if ($line->piece_num == $thisPieceNum)
                 {
                     print length_accounta($thisPieceAccountNr).$this->separator;
-                }
-                else {
+                } else {
                     print "div".$this->separator;
                 }
-            }
-            else {
+            } else {
                 print length_accounta($line->code_tiers).$this->separator;
             }
             //SId
@@ -959,8 +953,7 @@ class AccountancyExport
             if ($sammelBuchung)
             {
                 print "2".$this->separator;
-            }
-            else {
+            } else {
                 print "1".$this->separator;
             }
             // Code
@@ -969,8 +962,7 @@ class AccountancyExport
             if ($line->montant >= 0)
             {
                 print $line->montant.$this->separator;
-            }
-            else {
+            } else {
                 print ($line->montant * -1).$this->separator;
             }
             // Steuer

+ 6 - 12
htdocs/accountancy/class/accountingaccount.class.php

@@ -609,8 +609,7 @@ class AccountingAccount extends CommonObject
         if ($mode == 0)
         {
             $fieldtouse = 'active';
-        }
-        elseif ($mode == 1)
+        } elseif ($mode == 1)
         {
             $fieldtouse = 'reconcilable';
         }
@@ -661,28 +660,23 @@ class AccountingAccount extends CommonObject
 		{
 			if ($status == 1) return $langs->trans('Enabled');
 			elseif ($status == 0) return $langs->trans('Disabled');
-		}
-		elseif ($mode == 1)
+		} elseif ($mode == 1)
 		{
 			if ($status == 1) return $langs->trans('Enabled');
 			elseif ($status == 0) return $langs->trans('Disabled');
-		}
-		elseif ($mode == 2)
+		} elseif ($mode == 2)
 		{
 			if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled');
 			elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
-		}
-		elseif ($mode == 3)
+		} elseif ($mode == 3)
 		{
 			if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4');
 			elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5');
-		}
-		elseif ($mode == 4)
+		} elseif ($mode == 4)
 		{
 			if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled');
 			elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
-		}
-		elseif ($mode == 5)
+		} elseif ($mode == 5)
 		{
 			if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4');
 			elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5');

+ 3 - 6
htdocs/accountancy/class/accountingjournal.class.php

@@ -109,8 +109,7 @@ class AccountingJournal extends CommonObject
 			$sql .= " WHERE";
 			if ($rowid) {
 				$sql .= " rowid = ".(int) $rowid;
-			}
-			elseif ($journal_code)
+			} elseif ($journal_code)
 			{
 				$sql .= " code = '".$this->db->escape($journal_code)."'";
 				$sql .= " AND entity  = ".$conf->entity;
@@ -136,8 +135,7 @@ class AccountingJournal extends CommonObject
 				} else {
 					return 0;
 				}
-			}
-			else {
+			} else {
 				$this->error = "Error ".$this->db->lasterror();
 				$this->errors[] = "Error ".$this->db->lasterror();
 			}
@@ -310,8 +308,7 @@ class AccountingJournal extends CommonObject
 			elseif ($nature == 3) return $langs->trans('AccountingJournalType3');
 			elseif ($nature == 2) return $langs->trans('AccountingJournalType2');
 			elseif ($nature == 1) return $langs->trans('AccountingJournalType1');
-		}
-		elseif ($mode == 1)
+		} elseif ($mode == 1)
 		{
 			if ($nature == 9) return $langs->trans('AccountingJournalType9');
 			elseif ($nature == 5) return $langs->trans('AccountingJournalType5');

+ 2 - 4
htdocs/accountancy/class/bookkeeping.class.php

@@ -258,8 +258,7 @@ class BookKeeping extends CommonObject
 			if (in_array($this->doc_type, array('bank', 'expense_report')))
 			{
 				$this->errors[] = $langs->trans('ErrorFieldAccountNotDefinedForBankLine', $this->fk_docdet, $this->doc_type);
-			}
-			else {
+			} else {
 				//$this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForInvoiceLine', $this->doc_ref,  $this->label_compte);
 				$mesg = $this->doc_ref.', '.$langs->trans("AccountAccounting").': '.$this->numero_compte;
 				if ($this->subledger_account && $this->subledger_account != $this->numero_compte)
@@ -476,8 +475,7 @@ class BookKeeping extends CommonObject
 			}
 			$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
 			$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
-		}
-		else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
+		} else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
 
 		$linkstart = '<a href="'.$url.'"';
 		$linkstart .= $linkclose.'>';

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

@@ -59,8 +59,7 @@ if ($action == 'ventil' && $user->rights->accounting->bind->write)
 		$resql = $db->query($sql);
 		if (!$resql) {
 			setEventMessages($db->lasterror(), null, 'errors');
-		}
-		else {
+		} else {
 		    setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
 		    if ($backtopage)
 		    {

+ 5 - 10
htdocs/accountancy/customer/index.php

@@ -201,8 +201,7 @@ if ($action == 'validatehistory') {
 	if ($error)
 	{
 		$db->rollback();
-	}
-	else {
+	} else {
 		$db->commit();
 		setEventMessages($langs->trans('AutomaticBindingDone'), null, 'mesgs');
 	}
@@ -277,15 +276,13 @@ if ($resql) {
 		if ($row[0] == 'tobind')
 		{
 			print $langs->trans("Unknown");
-		}
-		else print length_accountg($row[0]);
+		} else print length_accountg($row[0]);
 		print '</td>';
 		print '<td class="left">';
 		if ($row[0] == 'tobind')
 		{
 			print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/customer/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind"));
-		}
-		else print $row[1];
+		} else print $row[1];
 		print '</td>';
 		for ($i = 2; $i <= 12; $i++) {
 			print '<td class="nowrap right">'.price($row[$i]).'</td>';
@@ -352,16 +349,14 @@ if ($resql) {
 		if ($row[0] == 'tobind')
 		{
 			print $langs->trans("Unknown");
-		}
-		else print length_accountg($row[0]);
+		} else print length_accountg($row[0]);
 		print '</td>';
 
 		print '<td class="left">';
 		if ($row[0] == 'tobind')
 		{
 			print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/customer/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind"));
-		}
-		else print $row[1];
+		} else print $row[1];
 		print '</td>';
 
 		for ($i = 2; $i <= 12; $i++) {

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

@@ -159,8 +159,7 @@ if ($massaction == 'ventil') {
             {
                 $msg .= '<div><font color="red">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'</font></div>';
                 $ko++;
-            }
-            else {
+            } else {
                 $sql = " UPDATE ".MAIN_DB_PREFIX."facturedet";
                 $sql .= " SET fk_code_ventilation = ".$monCompte;
                 $sql .= " WHERE rowid = ".$monId;
@@ -628,8 +627,7 @@ if ($result) {
 					$suggestedid = $tmpaccount->id;
 				}
 				$accountingaccount_codetotid_cache[$objp->code_sell_l] = $tmpaccount->id;
-			}
-			else {
+			} else {
 				$suggestedid = $accountingaccount_codetotid_cache[$objp->code_sell_l];
 			}
 		}

+ 1 - 2
htdocs/accountancy/expensereport/card.php

@@ -63,8 +63,7 @@ if ($action == 'ventil' && $user->rights->accounting->bind->write)
 		$resql = $db->query($sql);
 		if (!$resql) {
 			setEventMessages($db->lasterror(), null, 'errors');
-		}
-		else {
+		} else {
 			setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
 			if ($backtopage)
 			{

+ 4 - 8
htdocs/accountancy/expensereport/index.php

@@ -189,15 +189,13 @@ if ($resql) {
 		if ($row[0] == 'tobind')
 		{
 			print $langs->trans("Unknown");
-		}
-		else print length_accountg($row[0]);
+		} else print length_accountg($row[0]);
 		print '</td>';
 		print '<td class="left">';
 		if ($row[0] == 'tobind')
 		{
 			print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/expensereport/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind"));
-		}
-		else print $row[1];
+		} else print $row[1];
 		print '</td>';
     	for ($i = 2; $i <= 12; $i++) {
             print '<td class="nowrap right">'.price($row[$i]).'</td>';
@@ -260,16 +258,14 @@ if ($resql) {
 		if ($row[0] == 'tobind')
 		{
 			print $langs->trans("Unknown");
-		}
-		else print length_accountg($row[0]);
+		} else print length_accountg($row[0]);
 		print '</td>';
 
 		print '<td class="left">';
 		if ($row[0] == 'tobind')
 		{
 			print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/expensereport/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind"));
-		}
-		else print $row[1];
+		} else print $row[1];
 		print '</td>';
     	for ($i = 2; $i <= 12; $i++) {
             print '<td class="nowrap right">'.price($row[$i]).'</td>';

+ 1 - 2
htdocs/accountancy/expensereport/list.php

@@ -138,8 +138,7 @@ if ($massaction == 'ventil') {
             {
                 $msg .= '<div><font color="red">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'</font></div>';
                 $ko++;
-            }
-            else {
+            } else {
                 $sql = " UPDATE ".MAIN_DB_PREFIX."expensereport_det";
                 $sql .= " SET fk_code_ventilation = ".$monCompte;
                 $sql .= " WHERE rowid = ".$monId;

+ 1 - 2
htdocs/accountancy/index.php

@@ -240,8 +240,7 @@ if ($conf->accounting->enabled)
     print $boxlist;
 
     print '</div>';
-}
-else {
+} else {
     print load_fiche_titre($langs->trans("AccountancyArea"), '', 'accountancy');
 
 	print $langs->trans("Module10Desc")."<br>\n";

+ 28 - 56
htdocs/accountancy/journal/bankjournal.php

@@ -276,8 +276,7 @@ if ($result) {
 					// We save tabtype for a future use, to remember what kind of payment it is
 					$tabpay[$obj->rowid]['type'] = $links[$key]['type'];
 					$tabtype[$obj->rowid] = $links[$key]['type'];
-				}
-				elseif (in_array($links[$key]['type'], array('company', 'user')))
+				} elseif (in_array($links[$key]['type'], array('company', 'user')))
 				{
 					if ($tabpay[$obj->rowid]['type'] == 'unknown')
 					{
@@ -549,8 +548,7 @@ if (!$error && $action == 'writebookkeeping') {
 							$error++;
 							$errorforline++;
 							setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
-						}
-						else {
+						} else {
 							$error++;
 							$errorforline++;
 							setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
@@ -574,8 +572,7 @@ if (!$error && $action == 'writebookkeeping') {
 						if ($tabtype[$key] == 'banktransfert')
 						{
 							$reflabel .= dol_string_nohtmltag($langs->transnoentitiesnoconv('TransitionalAccount').' '.$account_transfer);
-						}
-						else {
+						} else {
 							$reflabel .= dol_string_nohtmltag($val['soclib']);
 						}
 
@@ -697,8 +694,7 @@ if (!$error && $action == 'writebookkeeping') {
 								$error++;
 								$errorforline++;
 								setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
-							}
-							else {
+							} else {
 								$error++;
 								$errorforline++;
 								setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
@@ -706,8 +702,7 @@ if (!$error && $action == 'writebookkeeping') {
 						}
 					}
 				}
-			}
-			else {	// If thirdparty unknown, output the waiting account
+			} else {	// If thirdparty unknown, output the waiting account
 				foreach ($tabbq[$key] as $k => $mt) {
 					if ($mt)
 					{
@@ -744,8 +739,7 @@ if (!$error && $action == 'writebookkeeping') {
 								$error++;
 								$errorforline++;
 								setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
-							}
-							else {
+							} else {
 								$error++;
 								$errorforline++;
 								setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
@@ -766,8 +760,7 @@ if (!$error && $action == 'writebookkeeping') {
 		if (!$errorforline)
 		{
 			$db->commit();
-		}
-		else {
+		} else {
 			//print 'KO for line '.$key.' '.$error.'<br>';
 			$db->rollback();
 
@@ -782,12 +775,10 @@ if (!$error && $action == 'writebookkeeping') {
 
 	if (empty($error) && count($tabpay) > 0) {
 		setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs');
-	}
-	elseif (count($tabpay) == $error)
+	} elseif (count($tabpay) == $error)
 	{
 		setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings');
-	}
-	else {
+	} else {
 		setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings');
 	}
 
@@ -873,8 +864,7 @@ if ($action == 'exportcsv') {		// ISO and not UTF8 !
 					if ($tabtype[$key] == 'banktransfert')
 					{
 						$reflabel .= dol_string_nohtmltag($langs->transnoentitiesnoconv('TransitionalAccount').' '.$account_transfer);
-					}
-					else {
+					} else {
 						$reflabel .= dol_string_nohtmltag($val['soclib']);
 					}
 
@@ -972,8 +962,7 @@ if (empty($action) || $action == 'view') {
 			print '<br>'.img_warning().' '.$langs->trans("TheJournalCodeIsNotDefinedOnSomeBankAccount");
 			print ' : '.$langs->trans("AccountancyAreaDescBank", 9, '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("BankAccounts").'</strong>');
 		}
-	}
-	else dol_print_error($db);
+	} else dol_print_error($db);
 
 
 	// Button to write into Ledger
@@ -992,8 +981,7 @@ if (empty($action) || $action == 'view') {
 	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").'" />';
-	}
-	else {
+	} 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>';
 	}
@@ -1065,8 +1053,7 @@ if (empty($action) || $action == 'view') {
 				if (empty($accounttoshow) || $accounttoshow == 'NotDefined')
 				{
 					print '<span class="error">'.$langs->trans("BankAccountNotDefined").'</span>';
-				}
-				else print $accounttoshow;
+				} else print $accounttoshow;
 				print "</td>";
 				// Subledger account
 				print "<td>";
@@ -1097,8 +1084,7 @@ if (empty($action) || $action == 'view') {
 					if ($tabtype[$key] == 'banktransfert')
 					{
 						$reflabel .= $langs->trans('TransitionalAccount').' '.$account_transfer;
-					}
-					else {
+					} else {
 						$reflabel .= $val['soclib'];
 					}
 
@@ -1126,12 +1112,10 @@ if (empty($action) || $action == 'view') {
 							if (empty($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) || $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE == '-1')
 							{
 								print '<span class="error">'.$langs->trans('UnknownAccountForThirdpartyAndWaitingAccountNotDefinedBlocking').'</span>';
-							}
-							else {
+							} else {
 								print '<span class="warning">'.$langs->trans('UnknownAccountForThirdparty', length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE)).'</span>'; // We will use a waiting account
 							}
-						}
-						else {
+						} else {
 							// We will refuse writing
 							$errorstring = 'UnknownAccountForThirdpartyBlocking';
 							if ($tabtype[$key] == 'payment')				$errorstring = 'MainAccountForCustomersNotDefined';
@@ -1142,8 +1126,7 @@ if (empty($action) || $action == 'view') {
 							if ($tabtype[$key] == 'member')					$errorstring = 'MainAccountForSubscriptionPaymentNotDefined';
 							print '<span class="error">'.$langs->trans($errorstring).'</span>';
 						}
-					}
-					else print $accounttoshow;
+					} else print $accounttoshow;
 					print "</td>";
 
 					// Subledger account
@@ -1167,12 +1150,10 @@ if (empty($action) || $action == 'view') {
 									} else {
 										print '<span class="warning">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknown", $tabcompany[$key]['code_compta']).'</span>';
 									}
-								}
-								else {
+								} else {
 									print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownBlocking").'</span>';
 								}
-							}
-							else print $accounttoshowsubledger;
+							} else print $accounttoshowsubledger;
 						}
 					}
 					print "</td>";
@@ -1278,57 +1259,49 @@ function getSourceDocRef($val, $typerecord)
 		$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"];
 		$ref = $langs->transnoentitiesnoconv("Invoice");
-	}
-	elseif ($typerecord == 'payment_supplier')
+	} 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"];
 		$ref = $langs->transnoentitiesnoconv("SupplierInvoice");
-	}
-	elseif ($typerecord == 'payment_expensereport')
+	} 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";
 		$ref = $langs->transnoentitiesnoconv("ExpenseReport");
-	}
-	elseif ($typerecord == 'payment_salary')
+	} 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"];
 		$ref = $langs->transnoentitiesnoconv("SalaryPayment");
-	}
-	elseif ($typerecord == 'sc')
+	} elseif ($typerecord == 'sc')
 	{
 		$sqlmid = 'SELECT sc.rowid as ref';
 		$sqlmid .= " FROM ".MAIN_DB_PREFIX."paiementcharge as sc";
 		$sqlmid .= " WHERE sc.rowid=".$val["paymentscid"];
 		$ref = $langs->transnoentitiesnoconv("SocialContribution");
-	}
-	elseif ($typerecord == 'payment_vat')
+	} elseif ($typerecord == 'payment_vat')
 	{
 		$sqlmid = 'SELECT v.rowid as ref';
 		$sqlmid .= " FROM ".MAIN_DB_PREFIX."tva as v";
 		$sqlmid .= " WHERE v.rowid=".$val["paymentvatid"];
 		$ref = $langs->transnoentitiesnoconv("PaymentVat");
-	}
-	elseif ($typerecord == 'payment_donation')
+	} 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"];
 		$ref = $langs->transnoentitiesnoconv("Donation");
-	}
-	elseif ($typerecord == 'payment_loan')
+	} 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"];
 		$ref = $langs->transnoentitiesnoconv("LoanPayment");
-	}
-	elseif ($typerecord == 'payment_various')
+	} elseif ($typerecord == 'payment_various')
 	{
 		$sqlmid = 'SELECT v.rowid as ref';
 		$sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_various as v";
@@ -1351,8 +1324,7 @@ function getSourceDocRef($val, $typerecord)
 			{
 				$ref .= ' '.$objmid->ref;
 			}
-		}
-		else dol_print_error($db);
+		} 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

+ 11 - 22
htdocs/accountancy/journal/expensereportsjournal.php

@@ -231,8 +231,7 @@ if ($action == 'writebookkeeping') {
 							$error++;
 							$errorforline++;
 							//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
-						}
-						else {
+						} else {
 							$error++;
 							$errorforline++;
 							setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
@@ -280,8 +279,7 @@ if ($action == 'writebookkeeping') {
 								$error++;
 								$errorforline++;
 								//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
-							}
-							else {
+							} else {
 								$error++;
 								$errorforline++;
 								setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
@@ -339,8 +337,7 @@ if ($action == 'writebookkeeping') {
 								$error++;
 								$errorforline++;
 								//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
-							}
-							else {
+							} else {
 								$error++;
 								$errorforline++;
 								setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
@@ -362,8 +359,7 @@ if ($action == 'writebookkeeping') {
 		if (!$errorforline)
 		{
 			$db->commit();
-		}
-		else {
+		} else {
 			$db->rollback();
 
 			if ($error >= 10)
@@ -378,12 +374,10 @@ if ($action == 'writebookkeeping') {
 
 	if (empty($error) && count($tabpay) > 0) {
 		setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs');
-	}
-	elseif (count($tabpay) == $error)
+	} elseif (count($tabpay) == $error)
 	{
 		setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings');
-	}
-	else {
+	} else {
 		setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings');
 	}
 
@@ -506,8 +500,7 @@ if (empty($action) || $action == 'view') {
 	if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL) && $in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />';
 	if (empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) || $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT == '-1') {
 		print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="'.$langs->trans("WriteBookKeeping").'" />';
-	}
-	else {
+	} else {
 		if ($in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans("WriteBookKeeping").'" onclick="writebookkeeping();" />';
 		else print '<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans("WriteBookKeeping").'</a>';
 	}
@@ -577,8 +570,7 @@ if (empty($action) || $action == 'view') {
 				if (($accountoshow == "") || $accountoshow == 'NotDefined')
 				{
 					print '<span class="error">'.$langs->trans("FeeAccountNotDefined").'</span>';
-				}
-				else print $accountoshow;
+				} else print $accountoshow;
 				print '</td>';
 				// Subledger account
 				print "<td>";
@@ -607,8 +599,7 @@ if (empty($action) || $action == 'view') {
 			if (($accountoshow == "") || $accountoshow == 'NotDefined')
 			{
 				print '<span class="error">'.$langs->trans("MainAccountForUsersNotDefined").'</span>';
-			}
-			else print $accountoshow;
+			} else print $accountoshow;
 			print "</td>";
 			// Subledger account
 			print "<td>";
@@ -616,8 +607,7 @@ if (empty($action) || $action == 'view') {
 			if (($accountoshow == "") || $accountoshow == 'NotDefined')
 			{
 				print '<span class="error">'.$langs->trans("UserAccountNotDefined").'</span>';
-			}
-			else print $accountoshow;
+			} else print $accountoshow;
 			print '</td>';
 			print "<td>".$userstatic->getNomUrl(0, 'user', 16).' - '.$langs->trans("SubledgerAccount")."</td>";
 			print '<td class="right nowraponall">'.($mt < 0 ? -price(-$mt) : '')."</td>";
@@ -644,8 +634,7 @@ if (empty($action) || $action == 'view') {
 					if (($accountoshow == "") || $accountoshow == 'NotDefined')
 					{
 						print '<span class="error">'.$langs->trans("VATAccountNotDefined").'</span>';
-					}
-					else print $accountoshow;
+					} else print $accountoshow;
 					print "</td>";
 					// Subledger account
 					print "<td>";

+ 14 - 28
htdocs/accountancy/journal/purchasesjournal.php

@@ -227,8 +227,7 @@ foreach ($tabfac as $key => $val) {		// Loop on each invoice
 		{
 			$errorforinvoice[$key] = 'somelinesarenotbound';
 		}
-	}
-	else dol_print_error($db);
+	} else dol_print_error($db);
 }
 //var_dump($errorforinvoice);exit;
 
@@ -332,8 +331,7 @@ if ($action == 'writebookkeeping') {
 						$errorforline++;
 						$errorforinvoice[$key] = 'alreadyjournalized';
 						//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
-					}
-					else {
+					} else {
 						$error++;
 						$errorforline++;
 						$errorforinvoice[$key] = 'other';
@@ -383,8 +381,7 @@ if ($action == 'writebookkeeping') {
 							$errorforline++;
 							$errorforinvoice[$key] = 'alreadyjournalized';
 							//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
-						}
-						else {
+						} else {
 							$error++;
 							$errorforline++;
 							$errorforinvoice[$key] = 'other';
@@ -445,8 +442,7 @@ if ($action == 'writebookkeeping') {
 								$errorforline++;
 								$errorforinvoice[$key] = 'alreadyjournalized';
 								//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
-							}
-							else {
+							} else {
 								$error++;
 								$errorforline++;
 								$errorforinvoice[$key] = 'other';
@@ -497,8 +493,7 @@ if ($action == 'writebookkeeping') {
 							$errorforline++;
 							$errorforinvoice[$key] = 'alreadyjournalized';
 							//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
-						}
-						else {
+						} else {
 							$error++;
 							$errorforline++;
 							$errorforinvoice[$key] = 'other';
@@ -521,8 +516,7 @@ if ($action == 'writebookkeeping') {
 		if (!$errorforline)
 		{
 			$db->commit();
-		}
-		else {
+		} else {
 			$db->rollback();
 
 			if ($error >= 10)
@@ -537,12 +531,10 @@ if ($action == 'writebookkeeping') {
 
 	if (empty($error) && count($tabpay) > 0) {
 		setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs');
-	}
-	elseif (count($tabpay) == $error)
+	} elseif (count($tabpay) == $error)
 	{
 		setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings');
-	}
-	else {
+	} else {
 		setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings');
 	}
 
@@ -738,8 +730,7 @@ if (empty($action) || $action == 'view') {
 	if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL) && $in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />';
 	if (($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").'" />';
-	}
-	else {
+	} else {
 		if ($in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans("WriteBookKeeping").'" onclick="writebookkeeping();" />';
 		else print '<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans("WriteBookKeeping").'</a>';
 	}
@@ -866,8 +857,7 @@ if (empty($action) || $action == 'view') {
 			if (($accountoshow == "") || $accountoshow == 'NotDefined')
 			{
 				print '<span class="error">'.$langs->trans("MainAccountForSuppliersNotDefined").'</span>';
-			}
-			else print $accountoshow;
+			} else print $accountoshow;
 			print '</td>';
 			// Subledger account
 			print "<td>";
@@ -875,8 +865,7 @@ if (empty($action) || $action == 'view') {
 			if (($accountoshow == "") || $accountoshow == 'NotDefined')
 			{
 				print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>';
-			}
-			else print $accountoshow;
+			} 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>";
@@ -899,8 +888,7 @@ if (empty($action) || $action == 'view') {
 			if (($accountoshow == "") || $accountoshow == 'NotDefined')
 			{
 				print '<span class="error">'.$langs->trans("ProductAccountNotDefined").'</span>';
-			}
-			else print $accountoshow;
+			} else print $accountoshow;
 			print "</td>";
 			// Subledger account
 			print "<td>";
@@ -932,8 +920,7 @@ if (empty($action) || $action == 'view') {
 					if (($accountoshow == "") || $accountoshow == 'NotDefined')
 					{
 						print '<span class="error">'.$langs->trans("VATAccountNotDefined").' ('.$langs->trans("Purchase").')</span>';
-					}
-					else print $accountoshow;
+					} else print $accountoshow;
 					print "</td>";
 					// Subledger account
 					print "<td>";
@@ -963,8 +950,7 @@ if (empty($action) || $action == 'view') {
 					if ($accountoshow == '' || $accountoshow == 'NotDefined')
 					{
 						print '<span class="error">'.$langs->trans("VATAccountNotDefined").' ('.$langs->trans("NPR counterpart").'). Set ACCOUNTING_COUNTERPART_VAT_NPR to the subvention account</span>';
-					}
-					else print $accountoshow;
+					} else print $accountoshow;
 					print '</td>';
 					// Subledger account
 					print "<td>";

+ 12 - 24
htdocs/accountancy/journal/sellsjournal.php

@@ -241,8 +241,7 @@ foreach ($tabfac as $key => $val) {		// Loop on each invoice
 		{
 			$errorforinvoice[$key] = 'somelinesarenotbound';
 		}
-	}
-	else dol_print_error($db);
+	} else dol_print_error($db);
 }
 //var_dump($errorforinvoice);exit;
 
@@ -343,8 +342,7 @@ if ($action == 'writebookkeeping') {
 						$errorforline++;
 						$errorforinvoice[$key] = 'alreadyjournalized';
 						//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
-					}
-					else {
+					} else {
 						$error++;
 						$errorforline++;
 						$errorforinvoice[$key] = 'other';
@@ -394,8 +392,7 @@ if ($action == 'writebookkeeping') {
 							$errorforline++;
 							$errorforinvoice[$key] = 'alreadyjournalized';
 							//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
-						}
-						else {
+						} else {
 							$error++;
 							$errorforline++;
 							$errorforinvoice[$key] = 'other';
@@ -455,8 +452,7 @@ if ($action == 'writebookkeeping') {
 								$errorforline++;
 								$errorforinvoice[$key] = 'alreadyjournalized';
 								//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
-							}
-							else {
+							} else {
 								$error++;
 								$errorforline++;
 								$errorforinvoice[$key] = 'other';
@@ -480,8 +476,7 @@ if ($action == 'writebookkeeping') {
 		if (!$errorforline)
 		{
 			$db->commit();
-		}
-		else {
+		} else {
 			$db->rollback();
 
 			if ($error >= 10)
@@ -496,11 +491,9 @@ if ($action == 'writebookkeeping') {
 
 	if (empty($error) && count($tabpay) > 0) {
 		setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs');
-	}
-	elseif (count($tabpay) == $error) {
+	} elseif (count($tabpay) == $error) {
 		setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings');
-	}
-	else {
+	} else {
 		setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings');
 	}
 
@@ -676,8 +669,7 @@ if (empty($action) || $action == 'view') {
 	if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL) && $in_bookkeeping == 'notyet') 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') {
 		print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="'.$langs->trans("WriteBookKeeping").'" />';
-	}
-	else {
+	} else {
 		if ($in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans("WriteBookKeeping").'" onclick="writebookkeeping();" />';
 		else print '<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans("WriteBookKeeping").'</a>';
 	}
@@ -803,8 +795,7 @@ if (empty($action) || $action == 'view') {
 			if (($accountoshow == "") || $accountoshow == 'NotDefined')
 			{
 				print '<span class="error">'.$langs->trans("MainAccountForCustomersNotDefined").'</span>';
-			}
-			else print $accountoshow;
+			} else print $accountoshow;
 			print '</td>';
 			// Subledger account
 			print "<td>";
@@ -812,8 +803,7 @@ if (empty($action) || $action == 'view') {
 			if (($accountoshow == "") || $accountoshow == 'NotDefined')
 			{
 				print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>';
-			}
-			else print $accountoshow;
+			} 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>";
@@ -837,8 +827,7 @@ if (empty($action) || $action == 'view') {
 			if (($accountoshow == "") || $accountoshow == 'NotDefined')
 			{
 				print '<span class="error">'.$langs->trans("ProductNotDefined").'</span>';
-			}
-			else print $accountoshow;
+			} else print $accountoshow;
 			print "</td>";
 			// Subledger account
 			print "<td>";
@@ -871,8 +860,7 @@ if (empty($action) || $action == 'view') {
 					if (($accountoshow == "") || $accountoshow == 'NotDefined')
 					{
 						print '<span class="error">'.$langs->trans("VATAccountNotDefined").' ('.$langs->trans("Sale").')</span>';
-					}
-					else print $accountoshow;
+					} else print $accountoshow;
 					print "</td>";
 					// Subledger account
 					print "<td>";

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

@@ -63,8 +63,7 @@ if ($action == 'ventil' && $user->rights->accounting->bind->write)
 		$resql = $db->query($sql);
 		if (!$resql) {
 			setEventMessages($db->lasterror(), null, 'errors');
-		}
-		else {
+		} else {
 		    setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
 		    if ($backtopage)
 		    {

+ 5 - 10
htdocs/accountancy/supplier/index.php

@@ -191,8 +191,7 @@ if ($action == 'validatehistory') {
 	if ($error)
 	{
 		$db->rollback();
-	}
-	else {
+	} else {
 		$db->commit();
 		setEventMessages($langs->trans('AutomaticBindingDone'), null, 'mesgs');
 	}
@@ -261,15 +260,13 @@ if ($resql) {
 		if ($row[0] == 'tobind')
 		{
 			print $langs->trans("Unknown");
-		}
-		else print length_accountg($row[0]);
+		} else print length_accountg($row[0]);
 		print '</td>';
 		print '<td class="left">';
 		if ($row[0] == 'tobind')
 		{
 			print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/supplier/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind"));
-		}
-		else print $row[1];
+		} else print $row[1];
 		print '</td>';
 		for ($i = 2; $i <= 12; $i++) {
 			print '<td class="nowrap right">'.price($row[$i]).'</td>';
@@ -331,15 +328,13 @@ if ($resql) {
 		if ($row[0] == 'tobind')
 		{
 			print $langs->trans("Unknown");
-		}
-		else print length_accountg($row[0]);
+		} else print length_accountg($row[0]);
 		print '</td>';
 		print '<td class="left">';
 		if ($row[0] == 'tobind')
 		{
 			print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/supplier/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind"));
-		}
-		else print $row[1];
+		} else print $row[1];
 		print '</td>';
     	for ($i = 2; $i <= 12; $i++) {
             print '<td class="nowrap right">'.price($row[$i]).'</td>';

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

@@ -163,8 +163,7 @@ if ($massaction == 'ventil') {
             {
                 $msg .= '<div><font color="red">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'</font></div>';
                 $ko++;
-            }
-            else {
+            } else {
                 $sql = " UPDATE ".MAIN_DB_PREFIX."facture_fourn_det";
                 $sql .= " SET fk_code_ventilation = ".$monCompte;
                 $sql .= " WHERE rowid = ".$monId;
@@ -608,8 +607,7 @@ if ($result) {
 					$suggestedid = $tmpaccount->id;
 				}
 				$accountingaccount_codetotid_cache[$objp->code_buy_l] = $tmpaccount->id;
-			}
-			else {
+			} else {
 				$suggestedid = $accountingaccount_codetotid_cache[$objp->code_buy_l];
 			}
 		}

+ 1 - 2
htdocs/accountancy/tpl/export_journal.tpl.php

@@ -58,8 +58,7 @@ if ($accountancyexport->getFormatCode($formatexportset) == $accountancyexport::$
 	$endaccountingperiod = dol_print_date(dol_get_last_day($tmparray['year'], $tmparray['mon']), 'dayxcard');
 
 	$completefilename = $siren."FEC".$endaccountingperiod.".txt";
-}
-else {
+} else {
 	$completefilename = ($code ? $code."_" : "").($prefix ? $prefix."_" : "").$filename.($nodateexport ? "" : $date_export).".".$format;
 }
 

+ 4 - 8
htdocs/api/admin/index.php

@@ -54,8 +54,7 @@ if ($action == 'setproductionmode')
 				setEventMessages($langs->trans("ErrorFailedToCreateDir", $conf->api->dir_temp), null, 'errors');
 				$error++;
 			}
-		}
-		else {
+		} else {
 			// Delete the cache file otherwise it does not update
 			$result = dol_delete_file($conf->api->dir_temp.'/routes.php');
 			if ($result < 0)
@@ -70,8 +69,7 @@ if ($action == 'setproductionmode')
     		header("Location: ".$_SERVER["PHP_SELF"]);
 	   	    exit;
 	    }
-	}
-	else {
+	} else {
 		dol_print_error($db);
 	}
 }
@@ -117,8 +115,7 @@ if ($production_mode)
     print '<td><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setproductionmode&value='.($i + 1).'&status=0">';
     print img_picto($langs->trans("Activated"), 'switch_on');
     print '</a></td>';
-}
-else {
+} else {
     print '<td><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setproductionmode&value='.($i + 1).'&status=1">';
     print img_picto($langs->trans("Disabled"), 'switch_off');
     print '</a></td>';
@@ -162,8 +159,7 @@ if (dol_is_dir(DOL_DOCUMENT_ROOT.'/includes/restler/framework/Luracast/Restler/e
 {
     $url = DOL_MAIN_URL_ROOT.'/api/index.php/explorer';
     print img_picto('', 'globe').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
-}
-else {
+} else {
     print $langs->trans("NotAvailableWithThisDistribution");
 }
 

+ 2 - 4
htdocs/api/class/api.class.php

@@ -250,8 +250,7 @@ class DolibarrApi
 		$featuresarray = array($resource);
 		if (preg_match('/&/', $resource)) {
 			$featuresarray = explode("&", $resource);
-		}
-		elseif (preg_match('/\|/', $resource)) {
+		} elseif (preg_match('/\|/', $resource)) {
 			$featuresarray = explode("|", $resource);
 		}
 
@@ -317,8 +316,7 @@ class DolibarrApi
 	    if (preg_match('/^\'(.*)\'$/', $tmpescaped, $regbis))
 	    {
 	        $tmpescaped = "'".$db->escape($regbis[1])."'";
-	    }
-	    else {
+	    } else {
 	        $tmpescaped = $db->escape($tmpescaped);
 	    }
 	    return $db->escape($tmp[0]).' '.strtoupper($db->escape($tmp[1]))." ".$tmpescaped;

+ 2 - 4
htdocs/api/class/api_access.class.php

@@ -128,8 +128,7 @@ class DolibarrApiAccess implements iAuthenticate
 						$conf->setValues($db);
 					}
 				}
-			}
-			else {
+			} else {
 				throw new RestException(503, 'Error when fetching user api_key :'.$db->error_msg);
 			}
 
@@ -157,8 +156,7 @@ class DolibarrApiAccess implements iAuthenticate
 			if ($fuser->admin) {
 				static::$role = 'admin';
             }
-        }
-		else {
+        } else {
 		    throw new RestException(401, "Failed to login to API. No parameter 'HTTP_DOLAPIKEY' on HTTP header (and no parameter DOLAPIKEY in URL).");
 		}
 

+ 1 - 2
htdocs/api/class/api_login.class.php

@@ -122,8 +122,7 @@ class Login
     		{
     			throw new RestException(500, 'Error when updating api_key for user :'.$this->db->lasterror());
     		}
-		}
-		else {
+		} else {
             $token = $tmpuser->api_key;
 		}
 

+ 12 - 24
htdocs/api/class/api_setup.class.php

@@ -878,8 +878,7 @@ class Setup extends DolibarrApi
         			$list[$tab->elementtype][$tab->name]['list'] = $tab->list;
         		}
         	}
-        }
-        else {
+        } else {
             throw new RestException(503, 'Error when retrieving list of extra fields : '.$this->db->lasterror());
         }
 
@@ -1483,12 +1482,10 @@ class Setup extends DolibarrApi
     		if (dol_is_file($xmlfile))
     		{
     			$xml = simplexml_load_file($xmlfile);
-    		}
-    		else {
+    		} else {
     			throw new RestException(500, $langs->trans('XmlNotFound').': '.$xmlfile);
     		}
-    	}
-    	else {
+    	} else {
     		$xmlarray = getURLContent($xmlremote);
 
     		// Return array('content'=>response,'curl_error_no'=>errno,'curl_error_msg'=>errmsg...)
@@ -1497,8 +1494,7 @@ class Setup extends DolibarrApi
     			$xmlfile = $xmlarray['content'];
     			//print "xmlfilestart".$xmlfile."endxmlfile";
     			$xml = simplexml_load_string($xmlfile);
-    		}
-    		else {
+    		} else {
     			$errormsg = $langs->trans('XmlNotFound').': '.$xmlremote.' - '.$xmlarray['http_code'].' '.$xmlarray['curl_error_no'].' '.$xmlarray['curl_error_msg'];
     			throw new RestException(500, $errormsg);
     		}
@@ -1605,8 +1601,7 @@ class Setup extends DolibarrApi
     					$out .= '<td class="center">'.$file['expectedmd5'].'</td>'."\n";
     					$out .= "</tr>\n";
     				}
-    			}
-    			else {
+    			} else {
     				$out .= '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
     			}
     			$out .= '</table>';
@@ -1654,8 +1649,7 @@ class Setup extends DolibarrApi
     				$out .= '<td class="right">'.dol_print_size($totalsize).'</td>'."\n";
     				$out .= '<td class="right"></td>'."\n";
     				$out .= "</tr>\n";
-    			}
-    			else {
+    			} else {
     				$out .= '<tr class="oddeven"><td colspan="5" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
     			}
     			$out .= '</table>';
@@ -1703,8 +1697,7 @@ class Setup extends DolibarrApi
     				$out .= '<td class="right">'.dol_print_size($totalsize).'</td>'."\n";
     				$out .= '<td class="right"></td>'."\n";
     				$out .= "</tr>\n";
-    			}
-    			else {
+    			} else {
     				$out .= '<tr class="oddeven"><td colspan="5" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
     			}
     			$out .= '</table>';
@@ -1715,12 +1708,10 @@ class Setup extends DolibarrApi
     			if (empty($tmpfilelist) && empty($tmpfilelist2) && empty($tmpfilelist3))
     			{
     				//setEventMessages($langs->trans("FileIntegrityIsStrictlyConformedWithReference"), null, 'mesgs');
-    			}
-    			else {
+    			} else {
     				//setEventMessages($langs->trans("FileIntegritySomeFilesWereRemovedOrModified"), null, 'warnings');
     			}
-    		}
-    		else {
+    		} else {
     			throw new RestException(500, 'Error: Failed to found dolibarr_htdocs_dir into XML file '.$xmlfile);
     		}
 
@@ -1742,22 +1733,19 @@ class Setup extends DolibarrApi
     				$resultcomment = 'FileIntegrityIsOkButFilesWereAdded';
     				//$outcurrentchecksum =  $checksumget.' - <span class="'.$resultcode.'">'.$langs->trans("FileIntegrityIsOkButFilesWereAdded").'</span>';
     				$outcurrentchecksum = $checksumget;
-    			}
-    			else {
+    			} else {
     				$resultcode = 'ok';
     				$resultcomment = 'Success';
     				//$outcurrentchecksum = '<span class="'.$resultcode.'">'.$checksumget.'</span>';
     				$outcurrentchecksum = $checksumget;
     			}
-    		}
-    		else {
+    		} else {
     			$resultcode = 'error';
     			$resultcomment = 'Error';
     			//$outcurrentchecksum = '<span class="'.$resultcode.'">'.$checksumget.'</span>';
     			$outcurrentchecksum = $checksumget;
     		}
-    	}
-    	else {
+    	} else {
     		throw new RestException(404, 'No signature file known');
     	}
 

+ 2 - 4
htdocs/api/index.php

@@ -202,13 +202,11 @@ if (!empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/swagger.json' || $
                                     {
                                         //dol_syslog("Found API by index.php: classname=".$classname."Api for module ".$dir." into ".$dir_part.$file_searched);
                                         $listofapis[strtolower($classname.'Api')] = $classname.'Api';
-                                    }
-                                    elseif (class_exists($classname))
+                                    } elseif (class_exists($classname))
                                     {
                                         //dol_syslog("Found API by index.php: classname=".$classname." for module ".$dir." into ".$dir_part.$file_searched);
                                         $listofapis[strtolower($classname)] = $classname;
-                                    }
-                                    else {
+                                    } else {
                                         dol_syslog("We found an api_xxx file (".$file_searched.") but class ".$classname." does not exists after loading file", LOG_WARNING);
                                     }
                                 }

+ 1 - 2
htdocs/asset/admin/setup.php

@@ -87,8 +87,7 @@ if ($action == 'edit')
 
 	print '</form>';
 	print '<br>';
-}
-else {
+} else {
 	print '<table class="noborder centpercent">';
 	print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
 

+ 2 - 4
htdocs/asset/card.php

@@ -314,16 +314,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
 			if ($user->rights->asset->write)
 			{
 				print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=edit">'.$langs->trans("Modify").'</a>'."\n";
-			}
-			else {
+			} else {
 				print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Modify').'</a>'."\n";
 			}
 
 			if ($user->rights->asset->delete)
 			{
 				print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete">'.$langs->trans('Delete').'</a>'."\n";
-			}
-			else {
+			} else {
 				print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Delete').'</a>'."\n";
 			}
 		}

+ 7 - 14
htdocs/asset/class/asset.class.php

@@ -351,8 +351,7 @@ class Asset extends CommonObject
 			}
 			$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
 			$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
-		}
-		else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
+		} else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
 
 		$linkstart = '<a href="'.$url.'"';
 		$linkstart .= $linkclose.'>';
@@ -395,28 +394,23 @@ class Asset extends CommonObject
 		{
 			if ($status == 1) return $langs->trans('Enabled');
 			elseif ($status == 0) return $langs->trans('Disabled');
-		}
-		elseif ($mode == 2)
+		} elseif ($mode == 2)
 		{
 			if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled');
 			elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
-		}
-		elseif ($mode == 3)
+		} elseif ($mode == 3)
 		{
 			if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4');
 			elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5');
-		}
-		elseif ($mode == 4)
+		} elseif ($mode == 4)
 		{
 			if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled');
 			elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
-		}
-		elseif ($mode == 5)
+		} elseif ($mode == 5)
 		{
 			if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4');
 			elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5');
-		}
-		elseif ($mode == 6)
+		} elseif ($mode == 6)
 		{
 			if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4');
 			elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5');
@@ -469,8 +463,7 @@ class Asset extends CommonObject
 			}
 
 			$this->db->free($result);
-		}
-		else {
+		} else {
 			dol_print_error($this->db);
 		}
 	}

+ 9 - 18
htdocs/asset/class/asset_type.class.php

@@ -154,14 +154,12 @@ class AssetType extends CommonObject
 			{
 				$this->db->commit();
 				return $this->id;
-			}
-			else {
+			} else {
 				dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR);
 				$this->db->rollback();
 				return -2;
 			}
-		}
-		else {
+		} else {
 			$this->error = $this->db->lasterror();
 			$this->db->rollback();
 			return -1;
@@ -221,14 +219,12 @@ class AssetType extends CommonObject
 			{
 				$this->db->commit();
 				return 1;
-			}
-			else {
+			} else {
 				$this->db->rollback();
 				dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR);
 				return -$error;
 			}
-		}
-		else {
+		} else {
 			$this->error = $this->db->lasterror();
 			$this->db->rollback();
 			return -1;
@@ -259,8 +255,7 @@ class AssetType extends CommonObject
 
 			$this->db->commit();
 			return 1;
-		}
-		else {
+		} else {
 			$this->db->rollback();
 			$this->error = $this->db->lasterror();
 			return -1;
@@ -298,8 +293,7 @@ class AssetType extends CommonObject
 			}
 
 			return 1;
-		}
-		else {
+		} else {
 			$this->error = $this->db->lasterror();
 			return -1;
 		}
@@ -338,8 +332,7 @@ class AssetType extends CommonObject
 					$i++;
 				}
 			}
-		}
-		else {
+		} else {
 			print $this->db->error();
 		}
 		return $assettypes;
@@ -383,8 +376,7 @@ class AssetType extends CommonObject
 							$assetstatic->fetch($obj->rowid);
 						}
 						$ret[$obj->rowid] = $assetstatic;
-					}
-					else $ret[$obj->rowid] = $obj->rowid;
+					} else $ret[$obj->rowid] = $obj->rowid;
 				}
 			}
 
@@ -393,8 +385,7 @@ class AssetType extends CommonObject
 			$this->asset = $ret;
 
 			return $ret;
-		}
-		else {
+		} else {
 			$this->error = $this->db->lasterror();
 			return -1;
 		}

+ 1 - 2
htdocs/asset/document.php

@@ -144,8 +144,7 @@ if ($object->id)
 	$relativepathwithnofile = 'asset/'.dol_sanitizeFileName($object->ref).'/';
 
 	include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
-}
-else {
+} else {
 	accessforbidden('', 0, 1);
 }
 

+ 2 - 4
htdocs/asset/list.php

@@ -253,8 +253,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit)))
 {
 	$num = $nbtotalofrecords;
-}
-else {
+} else {
 	if ($limit) $sql .= $db->plimit($limit + 1, $offset);
 
 	$resql = $db->query($sql);
@@ -387,8 +386,7 @@ foreach ($object->fields as $key => $val)
 		if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth75');
 		elseif (strpos($val['type'], 'integer:') === 0) {
 			print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1);
-		}
-		elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">';
+		} elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">';
 		print '</td>';
 	}
 }

+ 8 - 16
htdocs/asset/type.php

@@ -107,8 +107,7 @@ if ($action == 'add' && $user->rights->asset->write)
 	if (empty($object->label)) {
 		$error++;
 		setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors');
-	}
-	else {
+	} else {
 		$sql = "SELECT label FROM ".MAIN_DB_PREFIX."asset_type WHERE label='".$db->escape($object->label)."'";
 		$result = $db->query($sql);
 		if ($result) {
@@ -128,13 +127,11 @@ if ($action == 'add' && $user->rights->asset->write)
 		{
 			header("Location: ".$_SERVER["PHP_SELF"]);
 			exit;
-		}
-		else {
+		} else {
 			setEventMessages($object->error, $object->errors, 'errors');
 			$action = 'create';
 		}
-	}
-	else {
+	} else {
 		$action = 'create';
 	}
 }
@@ -160,8 +157,7 @@ if ($action == 'update' && $user->rights->asset->write)
 	if ($ret >= 0 && !count($object->errors))
 	{
 		setEventMessages($langs->trans("AssetsTypeModified"), null, 'mesgs');
-	}
-	else {
+	} else {
 		setEventMessages($object->error, $object->errors, 'errors');
 	}
 
@@ -179,8 +175,7 @@ if ($action == 'confirm_delete' && $user->rights->asset->write)
 		setEventMessages($langs->trans("AssetsTypeDeleted"), null, 'mesgs');
 		header("Location: ".$_SERVER["PHP_SELF"]);
 		exit;
-	}
-	else {
+	} else {
 		setEventMessages($langs->trans("AssetsTypeCanNotBeDeleted"), null, 'errors');
 		$action = '';
 	}
@@ -312,8 +307,7 @@ if (!$rowid && $action != 'create' && $action != 'edit')
 		print '</div>';
 
 		print '</form>';
-	}
-	else {
+	} else {
 		dol_print_error($db);
 	}
 }
@@ -361,8 +355,7 @@ if ($action == 'create')
 		print '<td>';
 		print $formaccounting->select_account($object->accountancy_code_depreciation_expense, 'accountancy_code_depreciation_expense', 1, '', 1, 1);
 		print '</td></tr>';
-	}
-	else // For external software
+	} else // For external software
 	{
 		// Accountancy_code_asset
 		print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeAsset").'</td>';
@@ -572,8 +565,7 @@ if ($rowid > 0)
 			print '<td>';
 			print $formaccounting->select_account($object->accountancy_code_depreciation_expense, 'accountancy_code_depreciation_expense', 1, '', 1, 1);
 			print '</td></tr>';
-		}
-		else // For external software
+		} else // For external software
 		{
 			// Accountancy_code_asset
 			print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeAsset").'</td>';

+ 10 - 20
htdocs/barcode/codeinit.php

@@ -71,8 +71,7 @@ if (!empty($conf->global->BARCODE_PRODUCT_ADDON_NUM))
 
 					try {
 						dol_include_once($dirroot.$file.'.php');
-					}
-					catch (Exception $e)
+					} catch (Exception $e)
 					{
 						dol_syslog($e->getMessage(), LOG_ERR);
 					}
@@ -109,13 +108,11 @@ if ($action == 'initbarcodeproducts')
 			if ($resql)
 			{
 				setEventMessages($langs->trans("AllBarcodeReset"), null, 'mesgs');
-			}
-			else {
+			} else {
 				$error++;
 				dol_print_error($db);
 			}
-		}
-		else {
+		} else {
 			$sql = "SELECT rowid, ref, fk_product_type";
 			$sql .= " FROM ".MAIN_DB_PREFIX."product";
 			$sql .= " WHERE barcode IS NULL or barcode = ''";
@@ -148,8 +145,7 @@ if ($action == 'initbarcodeproducts')
 
 					$i++;
 				}
-			}
-			else {
+			} else {
 				$error++;
 				dol_print_error($db);
 			}
@@ -164,8 +160,7 @@ if ($action == 'initbarcodeproducts')
 		{
 			//$db->rollback();
 			$db->commit();
-		}
-		else {
+		} else {
 			$db->rollback();
 		}
 	}
@@ -216,8 +211,7 @@ if ($conf->societe->enabled)
 	{
 		$obj = $db->fetch_object($resql);
 		$nbno = $obj->nb;
-	}
-	else dol_print_error($db);
+	} else dol_print_error($db);
 
 	$sql = "SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX."societe";
 	$resql = $db->query($sql);
@@ -225,8 +219,7 @@ if ($conf->societe->enabled)
 	{
 		$obj = $db->fetch_object($resql);
 		$nbtotal = $obj->nb;
-	}
-	else dol_print_error($db);
+	} else dol_print_error($db);
 
 	print $langs->trans("CurrentlyNWithoutBarCode", $nbno, $nbtotal, $langs->transnoentitiesnoconv("ThirdParties")).'<br>'."\n";
 
@@ -270,8 +263,7 @@ if ($conf->product->enabled || $conf->product->service)
 
 			$i++;
 		}
-	}
-	else dol_print_error($db);
+	} else dol_print_error($db);
 
 	$sql = "SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX."product";
 	$resql = $db->query($sql);
@@ -279,8 +271,7 @@ if ($conf->product->enabled || $conf->product->service)
 	{
 		$obj = $db->fetch_object($resql);
 		$nbtotal = $obj->nb;
-	}
-	else dol_print_error($db);
+	} else dol_print_error($db);
 
 	print $langs->trans("CurrentlyNWithoutBarCode", $nbno, $nbtotal, $langs->transnoentitiesnoconv("ProductsOrServices")).'<br>'."\n";
 
@@ -290,8 +281,7 @@ if ($conf->product->enabled || $conf->product->service)
 		$objproduct = new Product($db);
 		print '<b>'.(isset($modBarCodeProduct->name) ? $modBarCodeProduct->name : $modBarCodeProduct->nom).'</b> - '.$langs->trans("NextValue").': <b>'.$modBarCodeProduct->getNextValue($objproduct).'</b><br>';
 		$disabled = 0;
-	}
-	else {
+	} else {
 		$disabled = 1;
 		$titleno = $langs->trans("NoBarcodeNumberingTemplateDefined");
 		print '<font class="warning">'.$langs->trans("NoBarcodeNumberingTemplateDefined").'</font> (<a href="'.DOL_URL_ROOT.'/admin/barcode.php">'.$langs->trans("ToGenerateCodeDefineAutomaticRuleFirst").'</a>)<br>';

+ 1 - 2
htdocs/barcode/printsheet.php

@@ -161,8 +161,7 @@ if ($action == 'builddoc')
 					setEventMessages('Failed to generate image file of barcode for code='.$code.' encoding='.$encoding.' file='.basename($barcodeimage), null, 'errors');
 					setEventMessages($module->error, null, 'errors');
 				}
-			}
-			else {
+			} else {
 				$error++;
 				setEventMessages("Error, encoding ".$encoding." is not supported by encoder ".$generator.'. You must choose another barcode type or install a barcode generation engine that support '.$encoding, null, 'errors');
 			}

+ 2 - 4
htdocs/blockedlog/admin/blockedlog.php

@@ -51,8 +51,7 @@ if (preg_match('/set_(.*)/', $action, $reg))
 	{
 		header("Location: ".$_SERVER["PHP_SELF"]);
 		exit;
-	}
-	else {
+	} else {
 		dol_print_error($db);
 	}
 }
@@ -64,8 +63,7 @@ if (preg_match('/del_(.*)/', $action, $reg))
 	{
 		Header("Location: ".$_SERVER["PHP_SELF"]);
 		exit;
-	}
-	else {
+	} else {
 		dol_print_error($db);
 	}
 }

+ 8 - 16
htdocs/blockedlog/admin/blockedlog_list.php

@@ -133,13 +133,11 @@ if ($action === 'downloadblockchain') {
 			{
 				$previoushash = $block_static->getPreviousHash(0, $obj->rowid);
 				$firstid = $obj->rowid;
-			}
-			else {	// If not data found for filter, we do not need previoushash neither firstid
+			} else {	// If not data found for filter, we do not need previoushash neither firstid
 				$previoushash = 'nodata';
 				$firstid = '';
 			}
-		}
-		else {
+		} else {
 			$error++;
 			setEventMessages($db->lasterror, null, 'errors');
 		}
@@ -209,8 +207,7 @@ if ($action === 'downloadblockchain') {
 					$statusofrecord = 'Valid';
 					if ($loweridinerror > 0) $statusofrecordnote = 'ValidButFoundAPreviousKO';
 					else $statusofrecordnote = '';
-				}
-				else {
+				} else {
 					$statusofrecord = 'KO';
 					$statusofrecordnote = 'LineCorruptedOrNotMatchingPreviousOne';
 					$loweridinerror = $obj->rowid;
@@ -242,8 +239,7 @@ if ($action === 'downloadblockchain') {
 			}
 
 			exit;
-		}
-		else {
+		} else {
 			setEventMessages($db->lasterror, null, 'errors');
 		}
 	}
@@ -259,8 +255,7 @@ $form = new Form($db);
 if (GETPOST('withtab', 'alpha'))
 {
 	$title = $langs->trans("ModuleSetup").' '.$langs->trans('BlockedLog');
-}
-else {
+} else {
 	$title = $langs->trans("BrowseBlockedLog");
 }
 
@@ -274,8 +269,7 @@ if (!is_array($blocks))
 	if ($blocks == -2)
 	{
 		setEventMessages($langs->trans("TooManyRecordToScanRestrictFilters", $MAXLINES), null, 'errors');
-	}
-	else {
+	} else {
 		dol_print_error($block_static->db, $block_static->error, $block_static->errors);
 		exit;
 	}
@@ -434,8 +428,7 @@ if (!empty($conf->global->BLOCKEDLOG_SCAN_ALL_FOR_LOWERIDINERROR)) {
 
 	// TODO Make a full scan of table in reverse order of id of $block, so we can use the parameter $previoushash into checkSignature to save requests
 	// to find the $loweridinerror.
-}
-else {
+} else {
 	// This is version that optimize the memory (but will not report errors that are outside the filter range)
 	$loweridinerror = 0;
 	$checkresult = array();
@@ -503,8 +496,7 @@ if (is_array($blocks))
 		   	{
 		   		if ($checkresult[$block->id]) print img_picto($langs->trans('OkCheckFingerprintValidityButChainIsKo'), 'statut4');
 		   		else print img_picto($langs->trans('KoCheckFingerprintValidity'), 'statut8');
-		   	}
-		   	else {
+		   	} else {
 		   		print img_picto($langs->trans('OkCheckFingerprintValidity'), 'statut4');
 		   	}
 

+ 3 - 6
htdocs/blockedlog/ajax/authority.php

@@ -52,18 +52,15 @@ if ($auth->fetch(0, $signature) <= 0) {
 
 if (!empty($hash)) {
 	echo $auth->checkBlockchain($hash) ? 'hashisok' : 'hashisjunk';
-}
-elseif (!empty($newblock)) {
+} elseif (!empty($newblock)) {
 	if ($auth->checkBlock($newblock)) {
 		$auth->addBlock($newblock);
 		$auth->update($user);
 
 		echo 'blockadded';
-	}
-	else {
+	} else {
 		echo 'blockalreadyadded';
 	}
-}
-else {
+} else {
 	echo 'idontunderstandwhatihavetodo';
 }

+ 4 - 8
htdocs/blockedlog/ajax/block-info.php

@@ -51,8 +51,7 @@ if ($block->fetch($id) > 0)
 {
 	$objtoshow = $block->object_data;
 	print formatObject($objtoshow, '');
-}
-else {
+} else {
 	print 'Error, failed to get unalterable log with id '.$id;
 }
 
@@ -94,17 +93,14 @@ function formatObject($objtoshow, $prefix)
 					var_dump(@get_class($val));
 					var_dump($val);*/
 					$s .= dol_print_date($val, 'dayhour');
-				}
-				else {
+				} else {
 					$s .= $val;
 				}
 				$s .= '</td></tr>';
-			}
-			elseif (is_array($val))
+			} elseif (is_array($val))
 			{
 				$s .= formatObject($val, ($prefix ? $prefix.' > ' : '').$key);
-			}
-			elseif (is_object($val))
+			} elseif (is_object($val))
 			{
 				$s .= formatObject($val, ($prefix ? $prefix.' > ' : '').$key);
 			}

+ 7 - 14
htdocs/blockedlog/class/authority.class.php

@@ -128,8 +128,7 @@ class BlockedLogAuthority
 
 		if (!in_array($block, $blocks)) {
 			return true;
-		}
-		else {
+		} else {
 			return false;
 		}
     }
@@ -179,13 +178,11 @@ class BlockedLogAuthority
 				$this->tms = $this->db->jdate($obj->tms);
 
 				return 1;
-			}
-			else {
+			} else {
 				$this->error = $langs->trans("RecordNotFound");
 				return 0;
 			}
-		}
-		else {
+		} else {
 			$this->error = $this->db->error();
 			return -1;
 		}
@@ -230,13 +227,11 @@ class BlockedLogAuthority
 				$this->db->commit();
 
 				return $this->id;
-			}
-			else {
+			} else {
 				$this->db->rollback();
 				return -2;
 			}
-		}
-		else {
+		} else {
 			$this->error = $this->db->error();
 			$this->db->rollback();
 			return -1;
@@ -272,8 +267,7 @@ class BlockedLogAuthority
 			$this->db->commit();
 
 			return 1;
-		}
-		else {
+		} else {
 			$this->error = $this->db->error();
 			$this->db->rollback();
 			return -1;
@@ -311,8 +305,7 @@ class BlockedLogAuthority
 			echo $block->signature.' '.$url.' '.$res.'<br>';
 			if ($res === 'blockalreadyadded' || $res === 'blockadded') {
 				$block->setCertified();
-			}
-			else {
+			} else {
 				$this->error = $langs->trans('ImpossibleToContactAuthority ', $url);
 				return -1;
 			}

+ 43 - 86
htdocs/blockedlog/class/blockedlog.class.php

@@ -201,8 +201,7 @@ class BlockedLog
 			$object = new Facture($this->db);
 			if ($object->fetch($this->fk_object) > 0) {
 				return $object->getNomUrl(1);
-			}
-			else {
+			} else {
 				$this->error++;
 			}
 		}
@@ -212,98 +211,80 @@ class BlockedLog
 			$object = new FactureFournisseur($this->db);
 			if ($object->fetch($this->fk_object) > 0) {
 				return $object->getNomUrl(1);
-			}
-			else {
+			} else {
 				$this->error++;
 			}
-		}
-		elseif ($this->element === 'payment') {
+		} elseif ($this->element === 'payment') {
 			require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
 
 			$object = new Paiement($this->db);
 			if ($object->fetch($this->fk_object) > 0) {
 				return $object->getNomUrl(1);
-			}
-			else {
+			} else {
 				$this->error++;
 			}
-		}
-		elseif ($this->element === 'payment_supplier') {
+		} elseif ($this->element === 'payment_supplier') {
 			require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
 
 			$object = new PaiementFourn($this->db);
 			if ($object->fetch($this->fk_object) > 0) {
 				return $object->getNomUrl(1);
-			}
-			else {
+			} else {
 				$this->error++;
 			}
-		}
-		elseif ($this->element === 'payment_donation') {
+		} elseif ($this->element === 'payment_donation') {
 			require_once DOL_DOCUMENT_ROOT.'/don/class/paymentdonation.class.php';
 
 			$object = new PaymentDonation($this->db);
 			if ($object->fetch($this->fk_object) > 0) {
 				return $object->getNomUrl(1);
-			}
-			else {
+			} else {
 				$this->error++;
 			}
-		}
-		elseif ($this->element === 'payment_various') {
+		} elseif ($this->element === 'payment_various') {
 			require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php';
 
 			$object = new PaymentVarious($this->db);
 			if ($object->fetch($this->fk_object) > 0) {
 				return $object->getNomUrl(1);
-			}
-			else {
+			} else {
 				$this->error++;
 			}
-		}
-		elseif ($this->element === 'don' || $this->element === 'donation') {
+		} elseif ($this->element === 'don' || $this->element === 'donation') {
 			require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
 
 			$object = new Don($this->db);
 			if ($object->fetch($this->fk_object) > 0) {
 				return $object->getNomUrl(1);
-			}
-			else {
+			} else {
 				$this->error++;
 			}
-		}
-		elseif ($this->element === 'subscription') {
+		} elseif ($this->element === 'subscription') {
 			require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php';
 
 			$object = new Subscription($this->db);
 			if ($object->fetch($this->fk_object) > 0) {
 				return $object->getNomUrl(1);
-			}
-			else {
+			} else {
 				$this->error++;
 			}
-		}
-		elseif ($this->element === 'cashcontrol') {
+		} elseif ($this->element === 'cashcontrol') {
 			require_once DOL_DOCUMENT_ROOT.'/compta/cashcontrol/class/cashcontrol.class.php';
 
 			$object = new CashControl($this->db);
 			if ($object->fetch($this->fk_object) > 0) {
 				return $object->getNomUrl(1);
-			}
-			else {
+			} else {
 				$this->error++;
 			}
-		}
-		elseif ($this->action == 'MODULE_SET')
+		} elseif ($this->action == 'MODULE_SET')
 		{
 			return '<i class="opacitymedium">System to track events into unalterable logs were enabled</i>';
-		}
-		elseif ($this->action == 'MODULE_RESET')
+		} elseif ($this->action == 'MODULE_RESET')
 		{
 			if ($this->signature == '0000000000') {
 				return '<i class="opacitymedium">System to track events into unalterable logs were disabled after some recording were done. We saved a special Fingerprint to track the chain as broken.</i>';
-			}
-			else {
+			} else {
 				return '<i class="opacitymedium">System to track events into unalterable logs were disabled. This is possible because no record were done yet.</i>';
 			}
 		}
@@ -360,24 +341,19 @@ class BlockedLog
 		if ($object->element == 'payment' || $object->element == 'payment_supplier')
 		{
 			$this->date_object = $object->datepaye;
-		}
-		elseif ($object->element == 'payment_salary')
+		} elseif ($object->element == 'payment_salary')
 		{
 			$this->date_object = $object->datev;
-		}
-		elseif ($object->element == 'payment_donation' || $object->element == 'payment_various')
+		} elseif ($object->element == 'payment_donation' || $object->element == 'payment_various')
 		{
 			$this->date_object = $object->datepaid ? $object->datepaid : $object->datep;
-		}
-		elseif ($object->element == 'subscription')
+		} elseif ($object->element == 'subscription')
 		{
 			$this->date_object = $object->dateh;
-		}
-		elseif ($object->element == 'cashcontrol')
+		} elseif ($object->element == 'cashcontrol')
 		{
 			$this->date_object = $object->date_creation;
-		}
-		else {
+		} else {
 			$this->date_object = $object->date;
 		}
 		// ref
@@ -476,13 +452,11 @@ class BlockedLog
 							$this->object_data->invoiceline[$lineid]->{$keyline} = $valueline;
 						}
 					}
-				}
-				elseif (!is_object($value)) $this->object_data->{$key} = $value;
+				} elseif (!is_object($value)) $this->object_data->{$key} = $value;
 			}
 
 			if (!empty($object->newref)) $this->object_data->ref = $object->newref;
-		}
-		elseif ($this->element == 'invoice_supplier')
+		} elseif ($this->element == 'invoice_supplier')
 		{
 			foreach ($object as $key=>$value)
 			{
@@ -494,8 +468,7 @@ class BlockedLog
 			}
 
 			if (!empty($object->newref)) $this->object_data->ref = $object->newref;
-		}
-		elseif ($this->element == 'payment' || $this->element == 'payment_supplier' || $this->element == 'payment_donation' || $this->element == 'payment_various')
+		} elseif ($this->element == 'payment' || $this->element == 'payment_supplier' || $this->element == 'payment_donation' || $this->element == 'payment_various')
 		{
 			$datepayment = $object->datepaye ? $object->datepaye : ($object->datepaid ? $object->datepaid : $object->datep);
 			$paymenttypeid = $object->paiementid ? $object->paiementid : ($object->paymenttype ? $object->paymenttype : $object->type_payment);
@@ -527,18 +500,15 @@ class BlockedLog
 				{
 					include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
 					$tmpobject = new FactureFournisseur($this->db);
-				}
-				elseif ($this->element == 'payment')
+				} elseif ($this->element == 'payment')
 				{
 					include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
 					$tmpobject = new Facture($this->db);
-				}
-				elseif ($this->element == 'payment_donation')
+				} elseif ($this->element == 'payment_donation')
 				{
 					include_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
 					$tmpobject = new Don($this->db);
-				}
-				elseif ($this->element == 'payment_various')
+				} elseif ($this->element == 'payment_various')
 				{
 					include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php';
 					$tmpobject = new PaymentVarious($this->db);
@@ -571,8 +541,7 @@ class BlockedLog
 						$this->errors[] = $this->error;
 						dol_syslog("Failed to fetch thirdparty for object with id ".$tmpobject->id, LOG_ERR);
 						return -1;
-					}
-					elseif ($result < 0)
+					} elseif ($result < 0)
 					{
 						$this->error = $tmpobject->error;
 						$this->errors = $tmpobject->errors;
@@ -619,14 +588,12 @@ class BlockedLog
 			$this->object_data->amount = $totalamount;
 
 			if (!empty($object->newref)) $this->object_data->ref = $object->newref;
-		}
-		elseif ($this->element == 'payment_salary')
+		} elseif ($this->element == 'payment_salary')
 		{
 			$this->object_data->amounts = array($object->amount);
 
 			if (!empty($object->newref)) $this->object_data->ref = $object->newref;
-		}
-		elseif ($this->element == 'subscription')
+		} elseif ($this->element == 'subscription')
 		{
 			foreach ($object as $key=>$value)
 			{
@@ -638,8 +605,7 @@ class BlockedLog
 			}
 
 			if (!empty($object->newref)) $this->object_data->ref = $object->newref;
-		}
-		else // Generic case
+		} else // Generic case
 		{
 			foreach ($object as $key=>$value)
 			{
@@ -712,13 +678,11 @@ class BlockedLog
 				$this->certified		= ($obj->certified == 1);
 
 				return 1;
-			}
-			else {
+			} else {
 				$this->error = $langs->trans("RecordNotFound");
 				return 0;
 			}
-		}
-		else {
+		} else {
 			$this->error = $this->db->error();
 			return -1;
 		}
@@ -861,13 +825,11 @@ class BlockedLog
 				$this->db->commit();
 
 				return $this->id;
-			}
-			else {
+			} else {
 				$this->db->rollback();
 				return -2;
 			}
-		}
-		else {
+		} else {
 			$this->error = $this->db->error();
 			$this->db->rollback();
 			return -1;
@@ -948,8 +910,7 @@ class BlockedLog
 	 		{
 	 			$previoussignature = $obj->signature;
 	 		}
-	 	}
-	 	else {
+	 	} else {
 	 		dol_print_error($this->db);
 	 		exit;
 	 	}
@@ -989,16 +950,13 @@ class BlockedLog
 		if ($element == 'all') {
 	 		$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog
 	         WHERE entity=".$conf->entity;
-		}
-		elseif ($element == 'not_certified') {
+		} elseif ($element == 'not_certified') {
 			$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog
 	         WHERE entity=".$conf->entity." AND certified = 0";
-		}
-		elseif ($element == 'just_certified') {
+		} elseif ($element == 'just_certified') {
 			$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog
 	         WHERE entity=".$conf->entity." AND certified = 1";
-		}
-		else {
+		} else {
 			$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog
 	         WHERE entity=".$conf->entity." AND element='".$element."' AND fk_object=".(int) $fk_object;
 		}
@@ -1091,8 +1049,7 @@ class BlockedLog
 		{
 			$obj = $this->db->fetch_object($res);
 			if ($obj) $result = true;
-		}
-		else dol_print_error($this->db);
+		} else dol_print_error($this->db);
 
 		dol_syslog("Module Blockedlog alreadyUsed with ignoresystem=".$ignoresystem." is ".$result);
 

+ 2 - 4
htdocs/bom/bom_agenda.php

@@ -45,8 +45,7 @@ if (GETPOST('actioncode', 'array'))
 {
     $actioncode = GETPOST('actioncode', 'array', 3);
     if (!count($actioncode)) $actioncode = '0';
-}
-else {
+} else {
     $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
 }
 $search_agenda_label = GETPOST('search_agenda_label');
@@ -215,8 +214,7 @@ if ($object->id > 0)
     	if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create))
     	{
         	print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out.'">'.$langs->trans("AddAction").'</a>';
-    	}
-    	else {
+    	} else {
         	print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans("AddAction").'</a>';
     	}
     }

+ 5 - 10
htdocs/bom/bom_card.php

@@ -176,8 +176,7 @@ if (empty($reshook))
     		{
     			setEventMessages($bomline->error, $bomline->errors, 'errors');
     			$action = '';
-    		}
-    		else {
+    		} else {
     			unset($_POST['idprod']);
     			unset($_POST['qty']);
     			unset($_POST['qty_frozen']);
@@ -215,8 +214,7 @@ if (empty($reshook))
 		{
 			setEventMessages($bomline->error, $bomline->errors, 'errors');
 			$action = '';
-		}
-		else {
+		} else {
 			unset($_POST['idprod']);
 			unset($_POST['qty']);
 			unset($_POST['qty_frozen']);
@@ -618,8 +616,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
 	    		if ($permissiontoadd)
 	    		{
 	    			print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=edit">'.$langs->trans("Modify").'</a>'."\n";
-	    		}
-	    		else {
+	    		} else {
 	    			print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Modify').'</a>'."\n";
 	    		}
     		}
@@ -632,8 +629,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
 	    			if (is_array($object->lines) && count($object->lines) > 0)
 	    			{
 	    				print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=validate">'.$langs->trans("Validate").'</a>';
-	    			}
-	    			else {
+	    			} else {
 	    				$langs->load("errors");
 	    				print '<a class="butActionRefused" href="" title="'.$langs->trans("ErrorAddAtLeastOneLineFirst").'">'.$langs->trans("Validate").'</a>';
 	    			}
@@ -684,8 +680,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
     		if ($permissiontodelete)
     		{
     			print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete">'.$langs->trans('Delete').'</a>'."\n";
-    		}
-    		else {
+    		} else {
     			print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Delete').'</a>'."\n";
     		}
     	}

+ 1 - 2
htdocs/bom/bom_document.php

@@ -141,8 +141,7 @@ if ($object->id)
 	$relativepathwithnofile = 'bom/'.dol_sanitizeFileName($object->ref).'/';
 
 	include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
-}
-else {
+} else {
 	accessforbidden('', 0, 1);
 }
 

+ 8 - 16
htdocs/bom/bom_list.php

@@ -196,10 +196,8 @@ if (empty($reshook))
 						setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
 						$error++;
 						break;
-					}
-					else $nbok++;
-				}
-				else {
+					} else $nbok++;
+				} else {
 					setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
 					$error++;
 					break;
@@ -211,8 +209,7 @@ if (empty($reshook))
 				if ($nbok > 1) setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
 				else setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
 				$db->commit();
-			}
-			else {
+			} else {
 				$db->rollback();
 			}
 			//var_dump($listofobjectthirdparties);exit;
@@ -249,10 +246,8 @@ if (empty($reshook))
 						setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
 						$error++;
 						break;
-					}
-					else $nbok++;
-				}
-				else {
+					} else $nbok++;
+				} else {
 					setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
 					$error++;
 					break;
@@ -264,8 +259,7 @@ if (empty($reshook))
 				if ($nbok > 1) setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
 				else setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
 				$db->commit();
-			}
-			else {
+			} else {
 				$db->rollback();
 			}
 			//var_dump($listofobjectthirdparties);exit;
@@ -360,8 +354,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit)))
 {
 	$num = $nbtotalofrecords;
-}
-else {
+} else {
 	if ($limit) $sql .= $db->plimit($limit + 1, $offset);
 
 	$resql = $db->query($sql);
@@ -495,8 +488,7 @@ foreach ($object->fields as $key => $val)
 		if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth75');
 		elseif (strpos($val['type'], 'integer:') === 0) {
 			print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1);
-		}
-		elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">';
+		} elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">';
 		print '</td>';
 	}
 }

+ 2 - 4
htdocs/bom/class/api_boms.class.php

@@ -164,8 +164,7 @@ class Boms extends DolibarrApi
                 }
                 $i++;
             }
-        }
-        else {
+        } else {
             throw new RestException(503, 'Error when retrieve bom list');
         }
         if (!count($obj_ret)) {
@@ -228,8 +227,7 @@ class Boms extends DolibarrApi
         if ($this->bom->update($id, DolibarrApiAccess::$user) > 0)
         {
             return $this->get($id);
-        }
-        else {
+        } else {
             throw new RestException(500, $this->bom->error);
         }
     }

+ 15 - 30
htdocs/bom/class/bom.class.php

@@ -381,14 +381,11 @@ class BOM extends CommonObject
 			foreach ($filter as $key => $value) {
 				if ($key == 't.rowid') {
 					$sqlwhere[] = $key.'='.$value;
-				}
-				elseif (strpos($key, 'date') !== false) {
+				} elseif (strpos($key, 'date') !== false) {
 					$sqlwhere[] = $key.' = \''.$this->db->idate($value).'\'';
-				}
-				elseif ($key == 'customsql') {
+				} elseif ($key == 'customsql') {
 					$sqlwhere[] = $value;
-				}
-				else {
+				} else {
 					$sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\'';
 				}
 			}
@@ -513,14 +510,12 @@ class BOM extends CommonObject
 	        if ($numref != "")
 	        {
 	            return $numref;
-	        }
-	        else {
+	        } else {
 	            $this->error = $obj->error;
 	            //dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error);
 	            return "";
 	        }
-	    }
-	    else {
+	    } else {
 	        print $langs->trans("Error")." ".$langs->trans("Error_BOM_ADDON_NotDefined");
 	        return "";
 	    }
@@ -565,8 +560,7 @@ class BOM extends CommonObject
 	    {
 	        $this->fetch_product();
 	        $num = $this->getNextNumRef($this->product);
-	    }
-	    else {
+	    } else {
 	        $num = $this->ref;
 	    }
 	    $this->newref = dol_sanitizeFileName($num);
@@ -647,8 +641,7 @@ class BOM extends CommonObject
 	    {
 	        $this->db->commit();
 	        return 1;
-	    }
-	    else {
+	    } else {
 	        $this->db->rollback();
 	        return -1;
 	    }
@@ -784,8 +777,7 @@ class BOM extends CommonObject
              $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
              if ($reshook > 0) $linkclose = $hookmanager->resPrint;
              */
-        }
-        else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
+        } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
 
 		$linkstart = '<a href="'.$url.'"';
 		$linkstart .= $linkclose.'>';
@@ -891,8 +883,7 @@ class BOM extends CommonObject
 			}
 
 			$this->db->free($result);
-		}
-		else {
+		} else {
 			dol_print_error($this->db);
 		}
 	}
@@ -914,8 +905,7 @@ class BOM extends CommonObject
 	        $this->error = $this->error;
 	        $this->errors = $this->errors;
 	        return $result;
-	    }
-	    else {
+	    } else {
 	        $this->lines = $result;
 	        return $this->lines;
 	    }
@@ -1207,14 +1197,11 @@ class BOMLine extends CommonObjectLine
 			foreach ($filter as $key => $value) {
 				if ($key == 't.rowid') {
 					$sqlwhere[] = $key.'='.$value;
-				}
-				elseif (strpos($key, 'date') !== false) {
+				} elseif (strpos($key, 'date') !== false) {
 					$sqlwhere[] = $key.' = \''.$this->db->idate($value).'\'';
-				}
-				elseif ($key == 'customsql') {
+				} elseif ($key == 'customsql') {
 					$sqlwhere[] = $value;
-				}
-				else {
+				} else {
 					$sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\'';
 				}
 			}
@@ -1328,8 +1315,7 @@ class BOMLine extends CommonObjectLine
              $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
              if ($reshook > 0) $linkclose = $hookmanager->resPrint;
              */
-        }
-        else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
+        } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
 
 		$linkstart = '<a href="'.$url.'"';
 		$linkstart .= $linkclose.'>';
@@ -1422,8 +1408,7 @@ class BOMLine extends CommonObjectLine
 			}
 
 			$this->db->free($result);
-		}
-		else {
+		} else {
 			dol_print_error($this->db);
 		}
 	}

+ 1 - 2
htdocs/bom/tpl/objectline_create.tpl.php

@@ -99,8 +99,7 @@ if (!empty($conf->product->enabled) || !empty($conf->service->enabled))
 	{
 		// hide products in closed warehouse, but show products for internal transfer
 		$form->select_produits(GETPOST('idprod', 'int'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth500', 0, 'warehouseopen,warehouseinternal', GETPOST('combinations', 'array'));
-	}
-	else {
+	} else {
 		$form->select_produits(GETPOST('idprod', 'int'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth500', 0, '', GETPOST('combinations', 'array'));
 	}
 

+ 1 - 2
htdocs/bookmarks/admin/bookmark.php

@@ -44,8 +44,7 @@ if ($action == 'setvalue')
 	{
 		$db->commit();
 		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-	}
-	else {
+	} else {
 		$db->rollback();
 		setEventMessages($langs->trans("Error"), null, 'errors');
 	}

+ 2 - 4
htdocs/bookmarks/bookmarks.lib.php

@@ -41,8 +41,7 @@ function printDropdownBookmarksList()
     if (!empty($_SERVER["QUERY_STRING"]))
     {
         $url .= (dol_escape_htmltag($_SERVER["QUERY_STRING"]) ? '?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]) : '');
-    }
-    else {
+    } else {
         global $sortfield, $sortorder;
         $tmpurl = '';
         // No urlencode, all param $url will be urlencoded later
@@ -121,8 +120,7 @@ function printDropdownBookmarksList()
     		}
     		$searchForm .= '</select>';
     	}
-    }
-    else {
+    } else {
     	dol_print_error($db);
     }
 

+ 6 - 12
htdocs/bookmarks/card.php

@@ -100,20 +100,17 @@ if ($action == 'add' || $action == 'addproduct' || $action == 'update')
 			if (empty($backtopage)) $backtopage = ($urlsource ? $urlsource : ((!empty($url) && !preg_match('/^http/i', $url)) ? $url : DOL_URL_ROOT.'/bookmarks/list.php'));
 			header("Location: ".$backtopage);
 			exit;
-		}
-		else {
+		} else {
 			if ($object->errno == 'DB_ERROR_RECORD_ALREADY_EXISTS')
 			{
 				$langs->load("errors");
 				setEventMessages($langs->transnoentities("WarningBookmarkAlreadyExists"), null, 'warnings');
-			}
-			else {
+			} else {
 				setEventMessages($object->error, $object->errors, 'errors');
 			}
 			$action = $invertedaction;
 		}
-	}
-	else {
+	} else {
 		$action = $invertedaction;
 	}
 }
@@ -262,8 +259,7 @@ if ($id > 0 && !preg_match('/^add/i', $action))
 	{
 		$liste = array(1=>$langs->trans("OpenANewWindow"), 0=>$langs->trans("ReplaceWindow"));
 		print $form->selectarray('target', $liste, isset($_POST["target"]) ? $_POST["target"] : $object->target);
-	}
-	else {
+	} else {
 		if ($object->target == 0) print $langs->trans("ReplaceWindow");
 		if ($object->target == 1) print $langs->trans("OpenANewWindow");
 	}
@@ -273,15 +269,13 @@ if ($id > 0 && !preg_match('/^add/i', $action))
 	if ($action == 'edit' && $user->admin)
 	{
 		print img_picto('', 'user').' '.$form->select_dolusers(isset($_POST['userid']) ? $_POST['userid'] : ($object->fk_user ? $object->fk_user : ''), 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300');
-	}
-	else {
+	} else {
 		if ($object->fk_user > 0)
 		{
 			$fuser = new User($db);
 			$fuser->fetch($object->fk_user);
 			print $fuser->getNomUrl(1);
-		}
-		else {
+		} else {
 			print $langs->trans("Public");
 		}
 	}

+ 6 - 12
htdocs/bookmarks/class/bookmark.class.php

@@ -127,8 +127,7 @@ class Bookmark extends CommonObject
 
             $this->db->free($resql);
             return $this->id;
-        }
-        else {
+        } else {
             dol_print_error($this->db);
             return -1;
         }
@@ -173,15 +172,13 @@ class Bookmark extends CommonObject
                 $this->id = $id;
                 $this->db->commit();
                 return $id;
-            }
-            else {
+            } else {
                 $this->error = $this->db->lasterror();
                 $this->errno = $this->db->lasterrno();
                 $this->db->rollback();
                 return -2;
             }
-        }
-        else {
+        } else {
             $this->error = $this->db->lasterror();
             $this->errno = $this->db->lasterrno();
             $this->db->rollback();
@@ -215,8 +212,7 @@ class Bookmark extends CommonObject
         if ($this->db->query($sql))
         {
             return 1;
-        }
-        else {
+        } else {
             $this->error = $this->db->lasterror();
             return -1;
         }
@@ -238,8 +234,7 @@ class Bookmark extends CommonObject
         if ($resql)
         {
             return 1;
-        }
-        else {
+        } else {
             $this->error = $this->db->lasterror();
             return -1;
         }
@@ -315,8 +310,7 @@ class Bookmark extends CommonObject
 			}
 			$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
 			$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
-		}
-		else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
+		} else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
 
 		$linkstart = '<a href="'.$url.'"';
 		$linkstart .= $linkclose.'>';

+ 4 - 8
htdocs/bookmarks/list.php

@@ -72,8 +72,7 @@ if ($action == 'delete')
 	{
 		header("Location: ".$_SERVER["PHP_SELF"]);
 		exit;
-	}
-	else {
+	} else {
 		setEventMessages($object->error, $object->errors, 'errors');
 	}
 }
@@ -114,8 +113,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords)
 {
 	$num = $nbtotalofrecords;
-}
-else {
+} else {
 	$sql .= $db->plimit($limit + 1, $offset);
 
 	$resql = $db->query($sql);
@@ -228,8 +226,7 @@ while ($i < min($num, $limit))
 		}
 		$tmpuser = $cacheOfUsers[$obj->fk_user];
 		print $tmpuser->getNomUrl(1);
-	}
-	else {
+	} else {
 		print $langs->trans("Public");
 	}
 	print "</td>\n";
@@ -249,8 +246,7 @@ while ($i < min($num, $limit))
 	if ($user->rights->bookmark->supprimer)
 	{
 		print '<a class="marginleftonly" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$obj->rowid.'">'.img_delete().'</a>';
-	}
-	else {
+	} else {
 		print "&nbsp;";
 	}
 	print "</td>";

+ 3 - 6
htdocs/cashdesk/admin/cashdesk.php

@@ -68,8 +68,7 @@ if (GETPOST('action', 'alpha') == 'set')
     {
         $db->commit();
 	    setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    }
-    else {
+    } else {
         $db->rollback();
 	    setEventMessages($langs->trans("Error"), null, 'errors');
     }
@@ -148,8 +147,7 @@ if (!empty($conf->stock->enabled))
 	print '<td colspan="2">';
 	if (empty($conf->productbatch->enabled)) {
 	    print $form->selectyesno('CASHDESK_NO_DECREASE_STOCK', $conf->global->CASHDESK_NO_DECREASE_STOCK, 1);
-	}
-	else {
+	} else {
 	    if (!$conf->global->CASHDESK_NO_DECREASE_STOCK) {
 	        $res = dolibarr_set_const($db, "CASHDESK_NO_DECREASE_STOCK", 1, 'chaine', 0, '', $conf->entity);
 	    }
@@ -167,8 +165,7 @@ if (!empty($conf->stock->enabled))
 	{
 		print $formproduct->selectWarehouses($conf->global->CASHDESK_ID_WAREHOUSE, 'CASHDESK_ID_WAREHOUSE', '', 1, $disabled);
 		print ' <a href="'.DOL_URL_ROOT.'/product/stock/card.php?action=create&backtopage='.urlencode($_SERVER["PHP_SELF"]).'">('.$langs->trans("Create").')</a>';
-	}
-	else {
+	} else {
 		print '<span class="opacitymedium">'.$langs->trans("StockDecreaseForPointOfSaleDisabled").'</span>';
 	}
 	print '</td></tr>';

+ 2 - 4
htdocs/cashdesk/affContenu.php

@@ -36,8 +36,7 @@ if (isset($_SESSION['serObjFacturation']))
 {
     $obj_facturation = unserialize($_SESSION['serObjFacturation']);
     unset($_SESSION['serObjFacturation']);
-}
-else {
+} else {
 	// ... sinon, c'est une nouvelle vente
 	$obj_facturation = new Facturation();
 }
@@ -71,8 +70,7 @@ if (in_array(
 	))
 {
 	include $page.'.php';
-}
-else {
+} else {
 	dol_print_error('', 'menu param '.$page.' is not inside allowed list');
 }
 

+ 1 - 2
htdocs/cashdesk/class/Auth.class.php

@@ -129,8 +129,7 @@ class Auth
                 $this->login($aLogin);
                 $this->passwd($aPasswd);
                 $ret = 0;
-            }
-            else {
+            } else {
                 $ret = -1;
             }
         }

+ 12 - 24
htdocs/cashdesk/class/Facturation.class.php

@@ -294,12 +294,10 @@ class Facturation
         if (!$aId)
         {
             return $this->id;
-        }
-        elseif ($aId == 'RESET')
+        } elseif ($aId == 'RESET')
         {
             $this->id = null;
-        }
-        else {
+        } else {
             $this->id = $aId;
         }
     }
@@ -316,12 +314,10 @@ class Facturation
         if (is_null($aRef))
         {
             return $this->ref;
-        }
-        elseif ($aRef == 'RESET')
+        } elseif ($aRef == 'RESET')
         {
             $this->ref = null;
-        }
-        else {
+        } else {
             $this->ref = $aRef;
         }
     }
@@ -337,12 +333,10 @@ class Facturation
         if (is_null($aQte))
         {
             return $this->qte;
-        }
-        elseif ($aQte == 'RESET')
+        } elseif ($aQte == 'RESET')
         {
             $this->qte = null;
-        }
-        else {
+        } else {
             $this->qte = $aQte;
         }
     }
@@ -359,12 +353,10 @@ class Facturation
         if (is_null($aStock))
         {
             return $this->stock;
-        }
-        elseif ($aStock == 'RESET')
+        } elseif ($aStock == 'RESET')
         {
             $this->stock = null;
-        }
-        else {
+        } else {
             $this->stock = $aStock;
         }
     }
@@ -381,12 +373,10 @@ class Facturation
         if (is_null($aRemisePercent))
         {
             return $this->remise_percent;
-        }
-        elseif ($aRemisePercent == 'RESET')
+        } elseif ($aRemisePercent == 'RESET')
         {
             $this->remise_percent = null;
-        }
-        else {
+        } else {
             $this->remise_percent = $aRemisePercent;
         }
     }
@@ -577,12 +567,10 @@ class Facturation
         if (is_null($aTotalTtc))
         {
             return $this->prix_total_ttc;
-        }
-        elseif ($aTotalTtc == 'RESET')
+        } elseif ($aTotalTtc == 'RESET')
         {
             $this->prix_total_ttc = null;
-        }
-        else {
+        } else {
             $this->prix_total_ttc = $aTotalTtc;
         }
     }

+ 5 - 10
htdocs/cashdesk/facturation.php

@@ -80,8 +80,7 @@ if (GETPOST('filtre', 'alpha')) {
 			$i++;
 		}
 		$db->free($resql);
-	}
-	else {
+	} else {
 		dol_print_error($db);
 	}
 	$tab_designations = $ret;
@@ -114,8 +113,7 @@ if (GETPOST('filtre', 'alpha')) {
 			$i++;
 		}
 		$db->free($resql);
-	}
-	else {
+	} else {
 		dol_print_error($db);
 	}
 	$tab_designations = $ret;
@@ -128,16 +126,13 @@ if ($nbr_enreg > 1)
 	if ($nbr_enreg > $conf_taille_listes)
 	{
 		$top_liste_produits = '----- '.$conf_taille_listes.' '.$langs->transnoentitiesnoconv("CashDeskProducts").' '.$langs->trans("CashDeskOn").' '.$nbr_enreg.' -----';
-	}
-	else {
+	} else {
 		$top_liste_produits = '----- '.$nbr_enreg.' '.$langs->transnoentitiesnoconv("CashDeskProducts").' '.$langs->trans("CashDeskOn").' '.$nbr_enreg.' -----';
 	}
-}
-elseif ($nbr_enreg == 1)
+} elseif ($nbr_enreg == 1)
 {
 	$top_liste_produits = '----- 1 '.$langs->transnoentitiesnoconv("ProductFound").' -----';
-}
-else {
+} else {
 	$top_liste_produits = '----- '.$langs->transnoentitiesnoconv("NoProductFound").' -----';
 }
 

+ 2 - 4
htdocs/cashdesk/facturation_dhtml.php

@@ -55,8 +55,7 @@ if (dol_strlen($search) >= 0)	// If search criteria is on char length at least
 		$sql .= " AND (p.ref LIKE '".$db->escape($search)."%' OR p.label LIKE '".$db->escape($search)."%'";
 		if (!empty($conf->barcode->enabled)) $sql .= " OR p.barcode LIKE '".$db->escape($search)."%'";
 		$sql .= ")";
-	}
-	else {
+	} else {
 		$sql .= " AND (p.ref LIKE '%".$db->escape($search)."%' OR p.label LIKE '%".$db->escape($search)."%'";
 		if (!empty($conf->barcode->enabled)) $sql .= " OR p.barcode LIKE '%".$db->escape($search)."%'";
 		$sql .= ")";
@@ -97,8 +96,7 @@ if (dol_strlen($search) >= 0)	// If search criteria is on char length at least
 			$resultat .= '</ul>';
 
 			print $resultat;
-		}
-		else {
+		} else {
 			$langs->load("cashdesk");
 
 			print '<ul class="dhtml_bloc">';

+ 8 - 16
htdocs/cashdesk/facturation_verif.php

@@ -50,8 +50,7 @@ switch ($action)
 			if ($_POST['hdnSource'] == 'LISTE')
 			{
 				$sql .= " AND p.rowid = ".((int) GETPOST('selProduit', 'int'));
-			}
-			elseif ($_POST['hdnSource'] == 'REF')
+			} elseif ($_POST['hdnSource'] == 'REF')
 			{
 				$sql .= " AND p.ref = '".$db->escape(GETPOST('txtRef', 'alpha'))."'";
 			}
@@ -101,8 +100,7 @@ switch ($action)
 					        if (isset($prod->multiprices_tva_tx[$societe->price_level])) $tva_tx = $prod->multiprices_tva_tx[$societe->price_level];
 					        if (isset($prod->multiprices_recuperableonly[$societe->price_level])) $tva_npr = $prod->multiprices_recuperableonly[$societe->price_level];
 					    }
-					}
-					elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES))
+					} elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES))
 					{
 					    require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php';
 
@@ -123,8 +121,7 @@ switch ($action)
 					            $tva_npr = $prodcustprice->lines[0]->recuperableonly;
 					            if (empty($tva_tx)) $tva_npr = 0;
 					        }
-					    }
-					    else {
+					    } else {
 					        setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
 					    }
 					}
@@ -161,31 +158,26 @@ switch ($action)
 					if ($_POST['hdnSource'] == 'LISTE')
 					{
 						$filtre = $ret['ref'];
-					}
-					elseif ($_POST['hdnSource'] == 'REF')
+					} elseif ($_POST['hdnSource'] == 'REF')
 					{
 						$filtre = $_POST['txtRef'];
 					}
 
 					$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation&filtre='.$filtre;
-				}
-				else {
+				} else {
 					$obj_facturation->raz();
 
 					if ($_POST['hdnSource'] == 'REF')
 					{
 						$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation&filtre='.$_POST['txtRef'];
-					}
-					else {
+					} else {
 						$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation';
 					}
 				}
-			}
-			else {
+			} else {
 				dol_print_error($db);
 			}
-		}
-		else {
+		} else {
 			$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation';
 		}
 

+ 3 - 6
htdocs/cashdesk/index.php

@@ -75,8 +75,7 @@ if (is_array($hookmanager->resArray) && !empty($hookmanager->resArray)) {
 if (!empty($mysoc->logo_small))
 {
 	print '<img class="logopos" alt="Logo company" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;file='.urlencode('logos/thumbs/'.$mysoc->logo_small).'">';
-}
-else {
+} else {
 	print '<div class="logopos">'.$mysoc->name.'</div>';
 }
 ?>
@@ -112,8 +111,7 @@ if (!empty($morelogincontent)) {
 				echo $option;
 			}
 		}
-	}
-	else {
+	} else {
 		echo '<!-- Option by hook -->';
 		echo $morelogincontent;
 	}
@@ -202,8 +200,7 @@ if ($_GET['err'] < 0)
 	echo ('<script type="text/javascript">');
 	echo ('	document.getElementById(\'frmLogin\').pwdPassword.focus();');
 	echo ('</script>');
-}
-else {
+} else {
 	echo ('<script type="text/javascript">');
 	echo ('	document.getElementById(\'frmLogin\').txtUsername.focus();');
 	echo ('</script>');

+ 2 - 4
htdocs/cashdesk/index_verif.php

@@ -116,12 +116,10 @@ if ($retour >= 0)
 
 		header('Location: '.DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation&id=NOUV');
 		exit;
-	}
-	else {
+	} else {
 		dol_print_error($db);
 	}
-}
-else {
+} else {
 	// Load translation files required by the page
     $langs->loadLangs(array("other", "errors"));
 	$retour = $langs->trans("ErrorBadLoginPassword");

+ 3 - 6
htdocs/cashdesk/tpl/facturation1.tpl.php

@@ -169,24 +169,21 @@ for ($i = 0; $i < $nbtoshow; $i++)
 			{
 				$langs->load("errors");
 				print '<input class="bouton_mode_reglement_disabled" type="button" name="btnModeReglement" value="'.$langs->trans("Cash").'" title="'.dol_escape_htmltag($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("CashDesk"))).'" />';
-			}
-			else print '<input class="button bouton_mode_reglement" type="submit" name="btnModeReglement" value="'.$langs->trans("Cash").'" onclick="javascript: verifClic(\'ESP\');" />';
+			} else print '<input class="button bouton_mode_reglement" type="submit" name="btnModeReglement" value="'.$langs->trans("Cash").'" onclick="javascript: verifClic(\'ESP\');" />';
 			print '</div>';
 			print '<div class="inline-block" style="margin: 6px;">';
 			if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CB']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CB'] < 0)
 			{
 				$langs->load("errors");
 				print '<input class="bouton_mode_reglement_disabled" type="button" name="btnModeReglement" value="'.$langs->trans("CreditCard").'" title="'.dol_escape_htmltag($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("CashDesk"))).'" />';
-			}
-			else print '<input class="button bouton_mode_reglement" type="submit" name="btnModeReglement" value="'.$langs->trans("CreditCard").'" onclick="javascript: verifClic(\'CB\');" />';
+			} else print '<input class="button bouton_mode_reglement" type="submit" name="btnModeReglement" value="'.$langs->trans("CreditCard").'" onclick="javascript: verifClic(\'CB\');" />';
 			print '</div>';
 			print '<div class="inline-block" style="margin: 6px;">';
 			if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE'] < 0)
 			{
 				$langs->load("errors");
 				print '<input class="bouton_mode_reglement_disabled" type="button" name="btnModeReglement" value="'.$langs->trans("CheckBank").'" title="'.dol_escape_htmltag($langs->trans("ErrorModuleSetupNotComplete"), $langs->transnoentitiesnoconv("CashDesk")).'" />';
-			}
-			else print '<input class="button bouton_mode_reglement" type="submit" name="btnModeReglement" value="'.$langs->trans("CheckBank").'" onclick="javascript: verifClic(\'CHQ\');" />';
+			} else print '<input class="button bouton_mode_reglement" type="submit" name="btnModeReglement" value="'.$langs->trans("CheckBank").'" onclick="javascript: verifClic(\'CHQ\');" />';
 			print '</div>';
 			print '<div class="clearboth">';
 			print '<div class="inline-block" style="margin: 6px;">';

+ 1 - 2
htdocs/cashdesk/tpl/validation1.tpl.php

@@ -40,8 +40,7 @@ $langs->loadLangs(array("main", "bills", "banks"));
 // Affichage de la tva par taux
 if ($obj_facturation->montantTva()) {
 	echo ('<tr><td class="resume_label">'.$langs->trans("VAT").'</td><td>'.price(price2num($obj_facturation->montantTva(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency).'</td></tr>');
-}
-else {
+} else {
 	echo ('<tr><td class="resume_label">'.$langs->trans("VAT").'</td><td>'.$langs->trans("NoVAT").'</td></tr>');
 }
 ?>

+ 6 - 12
htdocs/cashdesk/validation_verif.php

@@ -96,8 +96,7 @@ switch ($action)
 			$encaisse = $obj_facturation->montantEncaisse();
 
 			$obj_facturation->montantRendu($encaisse - $total);
-		}
-		else {
+		} else {
 		    //$txtDatePaiement=$_POST['txtDatePaiement'];
 		    $datePaiement = dol_mktime(0, 0, 0, $_POST['txtDatePaiementmonth'], $_POST['txtDatePaiementday'], $_POST['txtDatePaiementyear']);
 		    $txtDatePaiement = dol_print_date($datePaiement, 'dayrfc');
@@ -251,15 +250,13 @@ switch ($action)
 						}
 					}
 				}
-			}
-			else {
+			} else {
 				setEventMessages($invoice->error, $invoice->errors, 'errors');
 			    $error++;
 			}
 
 			$id = $invoice->id;
-		}
-		else {
+		} else {
 		    $resultcreate = $invoice->create($user, 0, 0);
 			if ($resultcreate > 0)
 			{
@@ -327,13 +324,11 @@ switch ($action)
                   			//print 'set paid';exit;
                     	}
                     }
-				}
-				else {
+				} else {
 				    setEventMessages($invoice->error, $invoice->errors, 'errors');
 				    $error++;
 				}
-			}
-			else {
+			} else {
 				setEventMessages($invoice->error, $invoice->errors, 'errors');
 			    $error++;
 			}
@@ -344,8 +339,7 @@ switch ($action)
 		{
 			$db->commit();
 			$redirection = 'affIndex.php?menutpl=validation_ok&facid='.$id; // Ajout de l'id de la facture, pour l'inclure dans un lien pointant directement vers celle-ci dans Dolibarr
-		}
-		else {
+		} else {
 			$db->rollback();
 			$redirection = 'affIndex.php?facid='.$id.'&error=1&mesg=ErrorFailedToCreateInvoice'; // Ajout de l'id de la facture, pour l'inclure dans un lien pointant directement vers celle-ci dans Dolibarr
 		}

+ 4 - 8
htdocs/categories/admin/categorie.php

@@ -47,8 +47,7 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
     {
         header("Location: ".$_SERVER["PHP_SELF"]);
         exit;
-    }
-    else {
+    } else {
         setEventMessages($db->lasterror(), null, 'errors');
     }
 }
@@ -60,8 +59,7 @@ if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg))
     {
         header("Location: ".$_SERVER["PHP_SELF"]);
         exit;
-    }
-    else {
+    } else {
          setEventMessages($db->lasterror(), null, 'errors');
     }
 }
@@ -105,13 +103,11 @@ print '<td align="center" width="100">';
 if ($conf->use_javascript_ajax)
 {
 	print ajax_constantonoff('CATEGORIE_RECURSIV_ADD');
-}
-else {
+} else {
 	if (empty($conf->global->CATEGORIE_RECURSIV_ADD))
 	{
 		print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_CATEGORIE_RECURSIV_ADD">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
-	}
-	else {
+	} else {
 		print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_CATEGORIE_RECURSIV_ADD">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
 	}
 }

+ 15 - 30
htdocs/categories/card.php

@@ -88,38 +88,31 @@ if ($action == 'add' && $user->rights->categorie->creer)
 		{
 			header("Location: ".$urlfrom);
 			exit;
-		}
-		elseif ($idProdOrigin)
+		} elseif ($idProdOrigin)
 		{
 			header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idProdOrigin.'&type='.$type);
 			exit;
-		}
-		elseif ($idCompanyOrigin)
+		} elseif ($idCompanyOrigin)
 		{
 			header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idCompanyOrigin.'&type='.$type);
 			exit;
-		}
-		elseif ($idSupplierOrigin)
+		} elseif ($idSupplierOrigin)
 		{
 			header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idSupplierOrigin.'&type='.$type);
 			exit;
-		}
-		elseif ($idMemberOrigin)
+		} elseif ($idMemberOrigin)
 		{
 			header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idMemberOrigin.'&type='.$type);
 			exit;
-		}
-		elseif ($idContactOrigin)
+		} elseif ($idContactOrigin)
 		{
 			header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idContactOrigin.'&type='.$type);
 			exit;
-		}
-		elseif ($idProjectOrigin)
+		} elseif ($idProjectOrigin)
 		{
 			header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idProjectOrigin.'&type='.$type);
 			exit;
-		}
-		else {
+		} else {
 			header("Location: ".DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type);
 			exit;
 		}
@@ -154,8 +147,7 @@ if ($action == 'add' && $user->rights->categorie->creer)
 		{
 			$action = 'confirmed';
 			$_POST["addcat"] = '';
-		}
-		else {
+		} else {
 			setEventMessages($object->error, $object->errors, 'errors');
 		}
 	}
@@ -171,38 +163,31 @@ if (($action == 'add' || $action == 'confirmed') && $user->rights->categorie->cr
 		{
 			header("Location: ".$urlfrom);
 			exit;
-		}
-		elseif ($backtopage)
+		} elseif ($backtopage)
 		{
 			header("Location: ".$backtopage);
 			exit;
-		}
-		elseif ($idProdOrigin)
+		} elseif ($idProdOrigin)
 		{
 			header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idProdOrigin.'&type='.$type.'&mesg='.urlencode($langs->trans("CatCreated")));
 			exit;
-		}
-		elseif ($idCompanyOrigin)
+		} elseif ($idCompanyOrigin)
 		{
 			header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idCompanyOrigin.'&type='.$type.'&mesg='.urlencode($langs->trans("CatCreated")));
 			exit;
-		}
-		elseif ($idSupplierOrigin)
+		} elseif ($idSupplierOrigin)
 		{
 			header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idSupplierOrigin.'&type='.$type.'&mesg='.urlencode($langs->trans("CatCreated")));
 			exit;
-		}
-		elseif ($idMemberOrigin)
+		} elseif ($idMemberOrigin)
 		{
 			header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idMemberOrigin.'&type='.$type.'&mesg='.urlencode($langs->trans("CatCreated")));
 			exit;
-		}
-		elseif ($idContactOrigin)
+		} elseif ($idContactOrigin)
 		{
 			header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idContactOrigin.'&type='.$type.'&mesg='.urlencode($langs->trans("CatCreated")));
 			exit;
-		}
-		elseif ($idProjectOrigin)
+		} elseif ($idProjectOrigin)
 		{
 			header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idProjectOrigin.'&type='.$type.'&mesg='.urlencode($langs->trans("CatCreated")));
 			exit;

+ 2 - 4
htdocs/categories/class/api_categories.class.php

@@ -179,8 +179,7 @@ class Categories extends DolibarrApi
                 }
                 $i++;
             }
-        }
-        else {
+        } else {
             throw new RestException(503, 'Error when retrieve category list : '.$db->lasterror());
         }
         if (!count($obj_ret)) {
@@ -243,8 +242,7 @@ class Categories extends DolibarrApi
         if ($this->category->update(DolibarrApiAccess::$user) > 0)
         {
             return $this->get($id);
-        }
-        else {
+        } else {
             throw new RestException(500, $this->category->error);
         }
     }

+ 38 - 76
htdocs/categories/class/categorie.class.php

@@ -316,12 +316,10 @@ class Categorie extends CommonObject
 		if ($id > 0)
 		{
 			$sql .= " WHERE rowid = ".$id;
-		}
-		elseif (!empty($ref_ext))
+		} elseif (!empty($ref_ext))
 		{
 			$sql .= " WHERE ref_ext LIKE '".$this->db->escape($ref_ext)."'";
-		}
-		else {
+		} else {
 			$sql .= " WHERE label = '".$this->db->escape($label)."' AND entity IN (".getEntity('category').")";
 			if (!is_null($type)) $sql .= " AND type = ".$this->db->escape($type);
 		}
@@ -360,12 +358,10 @@ class Categorie extends CommonObject
 				if (!empty($conf->global->MAIN_MULTILANGS)) $this->getMultiLangs();
 
 				return 1;
-			}
-			else {
+			} else {
 				return 0;
 			}
-		}
-		else {
+		} else {
 			dol_print_error($this->db);
 			return -1;
 		}
@@ -479,18 +475,15 @@ class Categorie extends CommonObject
                 {
     				$this->db->commit();
     				return $id;
-                }
-                else {
+                } else {
                 	$this->db->rollback();
                     return -3;
                 }
-			}
-			else {
+			} else {
 				$this->db->rollback();
 				return -2;
 			}
-		}
-		else {
+		} else {
 			$this->error = $this->db->error();
 			$this->db->rollback();
 			return -1;
@@ -567,8 +560,7 @@ class Categorie extends CommonObject
 			$this->db->commit();
 
 			return 1;
-		}
-		else {
+		} else {
 			$this->db->rollback();
 			dol_print_error($this->db);
 			return -1;
@@ -653,8 +645,7 @@ class Categorie extends CommonObject
 		{
 			$this->db->commit();
 			return 1;
-		}
-		else {
+		} else {
 			$this->db->rollback();
 			return -1;
 		}
@@ -713,8 +704,7 @@ class Categorie extends CommonObject
 							}
 						}
 					}
-				}
-				else {
+				} else {
 					$error++;
 					$this->error = $this->db->lasterror();
 				}
@@ -738,20 +728,17 @@ class Categorie extends CommonObject
 			{
 			    $this->db->commit();
 			    return 1;
-			}
-			else {
+			} else {
 			    $this->db->rollback();
 			    return -2;
 			}
-		}
-		else {
+		} else {
 		    $this->db->rollback();
 			if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
 			{
 				$this->error = $this->db->lasterrno();
 				return -3;
-			}
-			else {
+			} else {
 				$this->error = $this->db->lasterror();
 			}
 			return -1;
@@ -802,13 +789,11 @@ class Categorie extends CommonObject
 			{
 			    $this->db->commit();
 			    return 1;
-			}
-			else {
+			} else {
 			    $this->db->rollback();
                 return -2;
 			}
-		}
-		else {
+		} else {
 		    $this->db->rollback();
 			$this->error = $this->db->lasterror();
 			return -1;
@@ -859,16 +844,14 @@ class Categorie extends CommonObject
 			    if ($onlyids)
 			    {
 			    	$objs[] = $rec['fk_'.(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])];
-			    }
-			    else {
+			    } else {
 				    $obj = new $this->MAP_OBJ_CLASS[$type]($this->db);
 				    $obj->fetch($rec['fk_'.(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])]);
 				    $objs[] = $obj;
 			    }
 			}
 			return $objs;
-		}
-		else {
+		} else {
 			$this->error = $this->db->error().' sql='.$sql;
 			return -1;
 		}
@@ -993,8 +976,7 @@ class Categorie extends CommonObject
 				}
 				$i++;
 			}
-		}
-		else {
+		} else {
 			$this->error = $this->db->lasterror();
 			return -1;
 		}
@@ -1029,8 +1011,7 @@ class Categorie extends CommonObject
 				$cats[] = $cat;
 			}
 			return $cats;
-		}
-		else {
+		} else {
 			dol_print_error($this->db);
 			return -1;
 		}
@@ -1062,8 +1043,7 @@ class Categorie extends CommonObject
 				$this->motherof[$obj->id_son] = $obj->id_parent;
 			}
 			return 1;
-		}
-		else {
+		} else {
 			dol_print_error($this->db);
 			return -1;
 		}
@@ -1099,18 +1079,15 @@ class Categorie extends CommonObject
         if (is_string($markafterid))
         {
             $markafterid = explode(',', $markafterid);
-        }
-        elseif (is_numeric($markafterid))
+        } elseif (is_numeric($markafterid))
         {
             if ($markafterid > 0)
             {
                 $markafterid = array($markafterid);
-            }
-            else {
+            } else {
                 $markafterid = array();
             }
-        }
-        elseif (!is_array($markafterid))
+        } elseif (!is_array($markafterid))
         {
             $markafterid = array();
         }
@@ -1146,8 +1123,7 @@ class Categorie extends CommonObject
 				$this->cats[$obj->rowid]['ref_ext'] = $obj->ref_ext;
 				$i++;
 			}
-		}
-		else {
+		} else {
 			dol_print_error($this->db);
 			return -1;
 		}
@@ -1291,8 +1267,7 @@ class Categorie extends CommonObject
 				$cats[$rec['rowid']] = $cat;
 			}
 			return $cats;
-		}
-		else {
+		} else {
 			dol_print_error($this->db);
 			return -1;
 		}
@@ -1354,8 +1329,7 @@ class Categorie extends CommonObject
 			}
 			dol_syslog(get_class($this)."::already_exists no category with same name=".$this->label." and same parent ".$this->fk_parent." than category id=".$this->id, LOG_DEBUG);
 			return 0;
-		}
-		else {
+		} else {
 			$this->error = $this->db->error();
 			return -1;
 		}
@@ -1407,8 +1381,7 @@ class Categorie extends CommonObject
 			        $link = '<a href="'.DOL_URL_ROOT.'/categories/viewcat.php?id='.$cat->id.'&type='.$cat->type.'" class="'.$forced_color.'">';
 			        $linkend = '</a>';
 			        $w[] = $link.($addpicto ? img_object('', 'category', 'class="paddingright"') : '').$cat->label.$linkend;
-				}
-				else {
+				} else {
 					$w[] = "<a href='".DOL_URL_ROOT."/".$url."?catid=".$cat->id."'>".($addpicto ? img_object('', 'category') : '').$cat->label."</a>";
 				}
 			}
@@ -1449,8 +1422,7 @@ class Categorie extends CommonObject
 				}
 			}
 			return $parents;
-		}
-		else {
+		} else {
 			dol_print_error($this->db);
 			return -1;
 		}
@@ -1529,13 +1501,11 @@ class Categorie extends CommonObject
     				    $cats[] = $cat;
     				}
 		        }
-		    }
-		    else {
+		    } else {
 		        dol_print_error($this->db);
 		        return -1;
 		    }
-		}
-        else {
+		} else {
     		$sql = "SELECT ct.fk_categorie, c.label, c.rowid";
     		$sql .= " FROM ".MAIN_DB_PREFIX."categorie_".(empty($this->MAP_CAT_TABLE[$type]) ? $type : $this->MAP_CAT_TABLE[$type])." as ct, ".MAIN_DB_PREFIX."categorie as c";
     		$sql .= " WHERE ct.fk_categorie = c.rowid AND ct.fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])." = ".(int) $id." AND c.type = ".$this->MAP_ID[$type];
@@ -1556,8 +1526,7 @@ class Categorie extends CommonObject
     					$cats[] = $cat;
     				}
     			}
-    		}
-    		else {
+    		} else {
     			dol_print_error($this->db);
     			return -1;
     		}
@@ -1623,8 +1592,7 @@ class Categorie extends CommonObject
 			}
 
 			return $cats;
-		}
-		else {
+		} else {
 			$this->error = $this->db->error().' sql='.$sql;
 			return -1;
 		}
@@ -1849,8 +1817,7 @@ class Categorie extends CommonObject
 	                $sql2 .= " SET label='".$this->db->escape($this->label)."',";
 	                $sql2 .= " description='".$this->db->escape($this->description)."'";
 	                $sql2 .= " WHERE fk_category=".$this->id." AND lang='".$this->db->escape($key)."'";
-	            }
-	            else {
+	            } else {
 	                $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."categorie_lang (fk_category, lang, label, description)";
 	                $sql2 .= " VALUES(".$this->id.",'".$key."','".$this->db->escape($this->label);
 	                $sql2 .= "','".$this->db->escape($this->multilangs["$key"]["description"])."')";
@@ -1861,8 +1828,7 @@ class Categorie extends CommonObject
 	                $this->error = $this->db->lasterror();
 	                return -1;
 	            }
-	        }
-	        elseif (isset($this->multilangs["$key"]))
+	        } elseif (isset($this->multilangs["$key"]))
 	        {
 	            if ($this->db->num_rows($result)) // si aucune ligne dans la base
 	            {
@@ -1870,8 +1836,7 @@ class Categorie extends CommonObject
 	                $sql2 .= " SET label='".$this->db->escape($this->multilangs["$key"]["label"])."',";
 	                $sql2 .= " description='".$this->db->escape($this->multilangs["$key"]["description"])."'";
 	                $sql2 .= " WHERE fk_category=".$this->id." AND lang='".$this->db->escape($key)."'";
-	            }
-	            else {
+	            } else {
 	                $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."categorie_lang (fk_category, lang, label, description)";
 	                $sql2 .= " VALUES(".$this->id.",'".$key."','".$this->db->escape($this->multilangs["$key"]["label"]);
 	                $sql2 .= "','".$this->db->escape($this->multilangs["$key"]["description"])."')";
@@ -1929,8 +1894,7 @@ class Categorie extends CommonObject
 	            $this->multilangs["$obj->lang"]["description"] = $obj->description;
 	        }
 	        return 1;
-	    }
-	    else {
+	    } else {
 	        $this->error = $langs->trans("Error")." : ".$this->db->error()." - ".$sql;
 	        return -1;
 	    }
@@ -2022,8 +1986,7 @@ class Categorie extends CommonObject
 			if (intval($searchCategory) == -2)
 			{
 				$searchCategorySqlList[] = " cp.fk_categorie IS NULL";
-			}
-			elseif (intval($searchCategory) > 0)
+			} elseif (intval($searchCategory) > 0)
 			{
 				$searchCategorySqlList[] = " ".$rowIdName
 										." IN (SELECT fk_".$type." FROM ".MAIN_DB_PREFIX."categorie_".$type
@@ -2034,8 +1997,7 @@ class Categorie extends CommonObject
 		if (!empty($searchCategorySqlList))
 		{
 			return " AND (".implode(' AND ', $searchCategorySqlList).")";
-		}
-		else {
+		} else {
 			return "";
 		}
 	}

+ 2 - 4
htdocs/categories/edit.php

@@ -108,12 +108,10 @@ if ($action == 'update' && $user->rights->categorie->creer)
 		{
 			header('Location: '.DOL_URL_ROOT.'/categories/viewcat.php?id='.$object->id.'&type='.$type);
 			exit;
-		}
-		else {
+		} else {
 			setEventMessages($object->error, $object->errors, 'errors');
 		}
-	}
-	else {
+	} else {
 		setEventMessages($object->error, $object->errors, 'errors');
 	}
 }

+ 2 - 4
htdocs/categories/index.php

@@ -134,8 +134,7 @@ if ($catname || $id > 0)
 		print "\t</tr>\n";
 	}
 	print "</table>";
-}
-else print '&nbsp;';
+} else print '&nbsp;';
 
 
 //print '</td></tr></table>';
@@ -206,8 +205,7 @@ if ($nbofentries > 0)
 	print '<tr class="pair"><td colspan="3">';
 	tree_recur($data, $data[0], 0);
 	print '</td></tr>';
-}
-else {
+} else {
 	print '<tr class="pair">';
 	print '<td colspan="3"><table class="nobordernopadding"><tr class="nobordernopadding"><td>'.img_picto_common('', 'treemenu/branchbottom.gif').'</td>';
 	print '<td valign="middle">';

+ 3 - 6
htdocs/categories/photos.php

@@ -179,8 +179,7 @@ if ($object->id)
 		{
 			print '<a class="butAction hideonsmartphone" href="'.$_SERVER['PHP_SELF'].'?action=ajout_photo&amp;id='.$object->id.'&amp;type='.$type.'">';
 			print $langs->trans("AddPhoto").'</a>';
-		}
-		else {
+		} else {
 			print '<a class="butActionRefused classfortooltip hideonsmartphone" href="#">';
 			print $langs->trans("AddPhoto").'</a>';
 		}
@@ -230,8 +229,7 @@ if ($object->id)
     			if ($obj['photo_vignette'])
     			{
     				$filename = $obj['photo_vignette'];
-    			}
-    			else {
+    			} else {
     				$filename = $obj['photo'];
     			}
 
@@ -278,8 +276,7 @@ if ($object->id)
 			print '<div class="opacitymedium">'.$langs->trans("NoPhotoYet")."</div>";
 		}
 	}
-}
-else {
+} else {
     print $langs->trans("ErrorUnknown");
 }
 

+ 1 - 2
htdocs/categories/traduction.php

@@ -292,8 +292,7 @@ if ($action == 'edit')
 	print '</div>';
 
 	print '</form>';
-}
-elseif ($action != 'add')
+} elseif ($action != 'add')
 {
     if ($cnt_trans) print '<div class="underbanner clearboth"></div>';
 

+ 31 - 62
htdocs/categories/viewcat.php

@@ -103,47 +103,40 @@ if ($id > 0 && $removeelem > 0)
 		$tmpobject = new Product($db);
 		$result = $tmpobject->fetch($removeelem);
 		$elementtype = 'product';
-	}
-	elseif ($type == Categorie::TYPE_SUPPLIER && $user->rights->societe->creer)
+	} elseif ($type == Categorie::TYPE_SUPPLIER && $user->rights->societe->creer)
 	{
 		$tmpobject = new Societe($db);
 		$result = $tmpobject->fetch($removeelem);
 		$elementtype = 'supplier';
-	}
-	elseif ($type == Categorie::TYPE_CUSTOMER && $user->rights->societe->creer)
+	} elseif ($type == Categorie::TYPE_CUSTOMER && $user->rights->societe->creer)
 	{
 		$tmpobject = new Societe($db);
 		$result = $tmpobject->fetch($removeelem);
 		$elementtype = 'customer';
-	}
-	elseif ($type == Categorie::TYPE_MEMBER && $user->rights->adherent->creer)
+	} elseif ($type == Categorie::TYPE_MEMBER && $user->rights->adherent->creer)
 	{
 		require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
 		$tmpobject = new Adherent($db);
 		$result = $tmpobject->fetch($removeelem);
 		$elementtype = 'member';
-	}
-	elseif ($type == Categorie::TYPE_CONTACT && $user->rights->societe->creer) {
+	} elseif ($type == Categorie::TYPE_CONTACT && $user->rights->societe->creer) {
 		require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
 		$tmpobject = new Contact($db);
 		$result = $tmpobject->fetch($removeelem);
 		$elementtype = 'contact';
-    }
-    elseif ($type == Categorie::TYPE_ACCOUNT && $user->rights->banque->configurer)
+    } elseif ($type == Categorie::TYPE_ACCOUNT && $user->rights->banque->configurer)
     {
         require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
         $tmpobject = new Account($db);
         $result = $tmpobject->fetch($removeelem);
         $elementtype = 'account';
-    }
-    elseif ($type == Categorie::TYPE_PROJECT && $user->rights->projet->creer)
+    } elseif ($type == Categorie::TYPE_PROJECT && $user->rights->projet->creer)
     {
         require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
         $tmpobject = new Project($db);
         $result = $tmpobject->fetch($removeelem);
         $elementtype = 'project';
-    }
-	elseif ($type == Categorie::TYPE_USER && $user->rights->user->user->creer)
+    } elseif ($type == Categorie::TYPE_USER && $user->rights->user->user->creer)
 	{
 		require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
 		$tmpobject = new User($db);
@@ -161,8 +154,7 @@ if ($user->rights->categorie->supprimer && $action == 'confirm_delete' && $confi
 	{
 		header("Location: ".DOL_URL_ROOT.'/categories/index.php?type='.$type);
 		exit;
-	}
-	else {
+	} else {
 		setEventMessages($object->error, $object->errors, 'errors');
 	}
 }
@@ -179,13 +171,11 @@ if ($type == Categorie::TYPE_PRODUCT && $elemid && $action == 'addintocategory'
 	if ($result >= 0)
 	{
 		setEventMessages($langs->trans("WasAddedSuccessfully", $newobject->ref), null, 'mesgs');
-	}
-	else {
+	} else {
 		if ($cat->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
 		{
 			setEventMessages($langs->trans("ObjectAlreadyLinkedToCategory"), null, 'warnings');
-		}
-		else {
+		} else {
 			setEventMessages($object->error, $object->errors, 'errors');
 		}
 	}
@@ -327,14 +317,12 @@ $cats = $object->get_filles();
 if ($cats < 0)
 {
 	dol_print_error($db, $cats->error, $cats->errors);
-}
-elseif (count($cats) < 1)
+} elseif (count($cats) < 1)
 {
 	print '<tr class="oddeven">';
 	print '<td colspan="3" class="opacitymedium">'.$langs->trans("NoSubCat").'</td>';
 	print '</tr>';
-}
-else {
+} else {
 	$categstatic = new Categorie($db);
 
 	$fulltree = $categstatic->get_full_arbo($type, $object->id, 1);
@@ -403,8 +391,7 @@ else {
 
 		print '</td>';
 		print '</tr>';
-	}
-	else {
+	} else {
 		print '<tr class="pair">';
 		print '<td colspan="3">';
 		print '<table class="nobordernopadding">';
@@ -445,8 +432,7 @@ if ($type == Categorie::TYPE_PRODUCT)
 	if ($prods < 0)
 	{
 		dol_print_error($db, $prods->error, $prods->errors);
-	}
-	else {
+	} else {
 		// Form to add record into a category
 		$showclassifyform = 1;
 		if ($showclassifyform)
@@ -508,8 +494,7 @@ if ($type == Categorie::TYPE_PRODUCT)
 				print '</td>';
 				print "</tr>\n";
 			}
-		}
-		else {
+		} else {
 			print '<tr class="oddeven"><td colspan="2" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</td></tr>';
 		}
 		print "</table>\n";
@@ -526,8 +511,7 @@ if ($type == Categorie::TYPE_SUPPLIER)
 	if ($socs < 0)
 	{
 		dol_print_error($db, $socs->error, $socs->errors);
-	}
-	else {
+	} else {
 		print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
 		print '<input type="hidden" name="token" value="'.newToken().'">';
 		print '<input type="hidden" name="typeid" value="'.$typeid.'">';
@@ -567,8 +551,7 @@ if ($type == Categorie::TYPE_SUPPLIER)
 
 				print "</tr>\n";
 			}
-		}
-		else {
+		} else {
 			print '<tr class="oddeven"><td colspan="2" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</td></tr>';
 		}
 		print "</table>\n";
@@ -585,8 +568,7 @@ if ($type == Categorie::TYPE_CUSTOMER)
 	if ($socs < 0)
 	{
 		dol_print_error($db, $socs->error, $socs->errors);
-	}
-	else {
+	} else {
 		print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
 		print '<input type="hidden" name="token" value="'.newToken().'">';
 		print '<input type="hidden" name="typeid" value="'.$typeid.'">';
@@ -625,8 +607,7 @@ if ($type == Categorie::TYPE_CUSTOMER)
 				print '</td>';
 				print "</tr>\n";
 			}
-		}
-		else {
+		} else {
 			print '<tr class="oddeven"><td colspan="2" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</td></tr>';
 		}
 		print "</table>\n";
@@ -646,8 +627,7 @@ if ($type == Categorie::TYPE_MEMBER)
 	if ($prods < 0)
 	{
 		dol_print_error($db, $prods->error, $prods->errors);
-	}
-	else {
+	} else {
 		print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
 		print '<input type="hidden" name="token" value="'.newToken().'">';
 		print '<input type="hidden" name="typeid" value="'.$typeid.'">';
@@ -688,8 +668,7 @@ if ($type == Categorie::TYPE_MEMBER)
 				}
 				print "</tr>\n";
 			}
-		}
-		else {
+		} else {
 			print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</td></tr>';
 		}
 		print "</table>\n";
@@ -707,8 +686,7 @@ if ($type == Categorie::TYPE_CONTACT)
 	if ($contacts < 0)
 	{
 		dol_print_error($db, $contacts->error, $contacts->errors);
-	}
-	else {
+	} else {
 		print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
 		print '<input type="hidden" name="token" value="'.newToken().'">';
 		print '<input type="hidden" name="typeid" value="'.$typeid.'">';
@@ -750,8 +728,7 @@ if ($type == Categorie::TYPE_CONTACT)
 				print '</td>';
 				print "</tr>\n";
 			}
-		}
-		else {
+		} else {
 			print '<tr class="oddeven"><td colspan="2" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</td></tr>';
 		}
 		print "</table>\n";
@@ -771,8 +748,7 @@ if ($type == Categorie::TYPE_ACCOUNT)
     if ($accounts < 0)
     {
         dol_print_error($db, $accounts->error, $accounts->errors);
-    }
-    else {
+    } else {
     	print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
     	print '<input type="hidden" name="token" value="'.newToken().'">';
     	print '<input type="hidden" name="typeid" value="'.$typeid.'">';
@@ -812,8 +788,7 @@ if ($type == Categorie::TYPE_ACCOUNT)
                 }
                 print "</tr>\n";
             }
-        }
-        else {
+        } else {
             print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</td></tr>';
         }
         print "</table>\n";
@@ -833,8 +808,7 @@ if ($type == Categorie::TYPE_PROJECT)
 	if ($objects < 0)
 	{
 		dol_print_error($db, $object->error, $object->errors);
-	}
-	else {
+	} else {
 		print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
 		print '<input type="hidden" name="token" value="'.newToken().'">';
 		print '<input type="hidden" name="typeid" value="'.$typeid.'">';
@@ -875,8 +849,7 @@ if ($type == Categorie::TYPE_PROJECT)
 				}
 				print "</tr>\n";
 			}
-		}
-		else {
+		} else {
 			print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</td></tr>';
 		}
 		print "</table>\n";
@@ -894,8 +867,7 @@ if ($type == Categorie::TYPE_USER)
 	if ($users < 0)
 	{
 		dol_print_error($db, $object->error, $object->errors);
-	}
-	else {
+	} else {
 		print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
 		print '<input type="hidden" name="token" value="'.newToken().'">';
 		print '<input type="hidden" name="typeid" value="'.$typeid.'">';
@@ -933,8 +905,7 @@ if ($type == Categorie::TYPE_USER)
 				}
 				print "</tr>\n";
 			}
-		}
-		else {
+		} else {
 			print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</td></tr>';
 		}
 		print "</table>\n";
@@ -955,8 +926,7 @@ if ($type == Categorie::TYPE_WAREHOUSE)
 	if ($objects < 0)
 	{
 		dol_print_error($db, $object->error, $object->errors);
-	}
-	else {
+	} else {
 		print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
 		print '<input type="hidden" name="token" value="'.newToken().'">';
 		print '<input type="hidden" name="typeid" value="'.$typeid.'">';
@@ -997,8 +967,7 @@ if ($type == Categorie::TYPE_WAREHOUSE)
 				}
 				print "</tr>\n";
 			}
-		}
-		else {
+		} else {
 			print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</td></tr>';
 		}
 		print "</table>\n";

+ 3 - 6
htdocs/collab/index.php

@@ -94,8 +94,7 @@ if ($action == 'add')
 		$db->commit();
 		setEventMessages($langs->trans("PageAdded", $objectpage->pageurl), null, 'mesgs');
 		$action = '';
-	}
-	else {
+	} else {
 		$db->rollback();
 	}
 
@@ -128,12 +127,10 @@ if ($action == 'delete')
 
 			header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website);
 			exit;
-		}
-		else {
+		} else {
 			$db->rollback();
 		}
-	}
-	else {
+	} else {
 		dol_print_error($db);
 	}
 }

+ 24 - 48
htdocs/comm/action/card.php

@@ -172,8 +172,7 @@ if (empty($reshook) && $action == 'confirm_clone' && $confirm == 'yes')
 	if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers'))
 	{
 		setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors');
-	}
-	else {
+	} else {
 		if ($id > 0) {
 			//$object->fetch($id);
             if (!empty($object->socpeopleassigned)) {
@@ -241,8 +240,7 @@ if (empty($reshook) && $action == 'add')
 		$error++; $donotclearsession = 1;
 		$action = 'create';
 		setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors');
-	}
-	else {
+	} else {
 		$object->type_code = GETPOST('actioncode', 'aZ09');
 	}
 
@@ -260,13 +258,11 @@ if (empty($reshook) && $action == 'add')
 			if (GETPOST('actioncode', 'aZ09') == 'AC_RDV' && $contact->getFullName($langs))
 			{
 				$object->label = $langs->transnoentitiesnoconv("TaskRDVWith", $contact->getFullName($langs));
-			}
-			else {
+			} else {
 				if ($langs->trans("Action".$object->type_code) != "Action".$object->type_code)
 				{
 					$object->label = $langs->transnoentitiesnoconv("Action".$object->type_code)."\n";
-				}
-				else {
+				} else {
 					$cactioncomm->fetch($object->type_code);
 					$object->label = $cactioncomm->label;
 				}
@@ -386,17 +382,14 @@ if (empty($reshook) && $action == 'add')
 				{
 					dol_syslog("Back to ".$backtopage.($moreparam ? (preg_match('/\?/', $backtopage) ? '&'.$moreparam : '?'.$moreparam) : ''));
 					header("Location: ".$backtopage.($moreparam ? (preg_match('/\?/', $backtopage) ? '&'.$moreparam : '?'.$moreparam) : ''));
-				}
-				elseif ($idaction)
+				} elseif ($idaction)
 				{
 					header("Location: ".DOL_URL_ROOT.'/comm/action/card.php?id='.$idaction.($moreparam ? '&'.$moreparam : ''));
-				}
-				else {
+				} else {
 					header("Location: ".DOL_URL_ROOT.'/comm/action/index.php'.($moreparam ? '?'.$moreparam : ''));
 				}
 				exit;
-			}
-			else {
+			} else {
 				// If error
 				$db->rollback();
 				$langs->load("errors");
@@ -404,8 +397,7 @@ if (empty($reshook) && $action == 'add')
 				setEventMessages($error, null, 'errors');
 				$action = 'create'; $donotclearsession = 1;
 			}
-		}
-		else {
+		} else {
 			$db->rollback();
 			setEventMessages($object->error, $object->errors, 'errors');
 			$action = 'create'; $donotclearsession = 1;
@@ -482,8 +474,7 @@ if (empty($reshook) && $action == 'update')
 			{
 				if ($val['id'] > 0 && $val['id'] != $assignedtouser) $listofuserid[$val['id']] = $val;
 			}
-		}
-		else {
+		} else {
 			$assignedtouser = (!empty($object->userownerid) && $object->userownerid > 0 ? $object->userownerid : 0);
 			if ($assignedtouser) $listofuserid[$assignedtouser] = array('id'=>$assignedtouser, 'mandatory'=>0, 'transparency'=>($user->id == $assignedtouser ? $transparency : '')); // Owner first
 		}
@@ -510,8 +501,7 @@ if (empty($reshook) && $action == 'update')
 			$error++; $donotclearsession = 1;
 			$action = 'edit';
 			setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors');
-		}
-		else {
+		} else {
 			$result = $cactioncomm->fetch(GETPOST('actioncode', 'aZ09'));
 		}
 		if (empty($object->userownerid))
@@ -599,8 +589,7 @@ if (empty($reshook) && $action == 'update')
 				unset($_SESSION['assignedtouser']);
 
 				$db->commit();
-			}
-			else {
+			} else {
 				setEventMessages($object->error, $object->errors, 'errors');
 				$db->rollback();
 			}
@@ -637,8 +626,7 @@ if (empty($reshook) && $action == 'confirm_delete' && GETPOST("confirm") == 'yes
 		{
 			header("Location: index.php");
 			exit;
-		}
-		else {
+		} else {
 			setEventMessages($object->error, $object->errors, 'errors');
 		}
 	}
@@ -746,8 +734,7 @@ if (empty($reshook) && GETPOST('actionmove', 'alpha') == 'mupdate')
     {
         header("Location: ".$backtopage);
         exit;
-    }
-    else {
+    } else {
         $action = '';
     }
 }
@@ -969,8 +956,7 @@ if ($action == 'create')
 		if ($assignedtouser) $listofuserid[$assignedtouser] = array('id'=>$assignedtouser, 'mandatory'=>0, 'transparency'=>$object->transparency); // Owner first
 		$listofuserid[$user->id]['transparency'] = GETPOSTISSET('transparency') ?GETPOST('transparency', 'alpha') : 1; // 1 by default at first init
 		$_SESSION['assignedtouser'] = json_encode($listofuserid);
-	}
-	else {
+	} else {
 		if (!empty($_SESSION['assignedtouser']))
 		{
 			$listofuserid = json_decode($_SESSION['assignedtouser'], true);
@@ -1022,8 +1008,7 @@ if ($action == 'create')
 			$societe->fetch(GETPOST('socid', 'int'));
 			print $societe->getNomUrl(1);
 			print '<input type="hidden" id="socid" name="socid" value="'.GETPOST('socid', 'int').'">';
-		}
-		else {
+		} else {
 			$events = array();
 			$events[] = array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php?showempty=1', 1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled'));
 			//For external user force the company to user company
@@ -1252,8 +1237,7 @@ if ($id > 0)
 		    if ($object->type_code != 'AC_OTH_AUTO')
 		    {
 		    	$formactions->select_type_actions(GETPOST("actioncode", 'aZ09') ?GETPOST("actioncode", 'aZ09') : $object->type_code, "actioncode", "systemauto");
-		    }
-		    else {
+		    } else {
                 print '<input type="hidden" name="actioncode" value="'.$object->type_code.'">'.$langs->trans("Action".$object->type_code);
 		    }
 			print '</td></tr>';
@@ -1383,8 +1367,7 @@ if ($id > 0)
 	    		}
 	    	}
 	    	$_SESSION['assignedtouser'] = json_encode($listofuserid);
-	    }
-	    else {
+	    } else {
 	    	if (!empty($_SESSION['assignedtouser']))
 	    	{
 	    		$listofuserid = json_decode($_SESSION['assignedtouser'], true);
@@ -1507,8 +1490,7 @@ if ($id > 0)
 			    print '<input type="hidden" name="elementtype" value="'.$object->elementtype.'">';
 
 			    print '</td>';
-			}
-			else {
+			} else {
 			    print '<td>';
 			    print dolGetElementUrl($object->fk_element, $object->elementtype, 1);
 			    print '<input type="hidden" name="fk_element" value="'.$object->fk_element.'">';
@@ -1547,8 +1529,7 @@ if ($id > 0)
 		print '</div>';
 
 		print '</form>';
-	}
-	else {
+	} else {
 		dol_fiche_head($head, 'card', $langs->trans("Action"), -1, 'action');
 
 
@@ -1691,8 +1672,7 @@ if ($id > 0)
 				}
 			}
 			$_SESSION['assignedtouser'] = json_encode($listofuserid);
-		}
-		else {
+		} else {
 			if (!empty($_SESSION['assignedtouser']))
 			{
 				$listofuserid = json_decode($_SESSION['assignedtouser'], true);
@@ -1778,8 +1758,7 @@ if ($id > 0)
 						print '<div class="paddingright"></div>';
 					}
 				}
-			}
-			else {
+			} else {
 				print '<span class="opacitymedium">'.$langs->trans("None").'</span>';
 			}
 			print '</td></tr>';
@@ -1836,8 +1815,7 @@ if ($id > 0)
 			   (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create))
 			{
 				print '<div class="inline-block divButAction"><a class="butAction" href="card.php?action=edit&id='.$object->id.'">'.$langs->trans("Modify").'</a></div>';
-			}
-			else {
+			} else {
 				print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans("Modify").'</a></div>';
 			}
 
@@ -1845,8 +1823,7 @@ if ($id > 0)
 			   (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create))
 			{
 				print '<div class="inline-block divButAction"><a class="butAction" href="card.php?action=clone&object='.$object->element.'&id='.$object->id.'">'.$langs->trans("ToClone").'</a></div>';
-			}
-			else {
+			} else {
 				print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans("ToClone").'</a></div>';
 			}
 
@@ -1854,8 +1831,7 @@ if ($id > 0)
 			   (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->delete))
 			{
 				print '<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?action=delete&id='.$object->id.'">'.$langs->trans("Delete").'</a></div>';
-			}
-			else {
+			} else {
 				print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans("Delete").'</a></div>';
 			}
 		}

+ 24 - 48
htdocs/comm/action/class/actioncomm.class.php

@@ -417,13 +417,11 @@ class ActionComm extends CommonObject
             {
                 $this->type_id = $cactioncomm->id;
                 $this->type_code = $cactioncomm->code;
-            }
-            elseif ($result == 0)
+            } elseif ($result == 0)
             {
                 $this->error = 'Failed to get record with id '.$this->type_id.' code '.$this->type_code.' from dictionary "type of events"';
                 return -1;
-            }
-            else {
+            } else {
                 $this->error = $cactioncomm->error;
                 return -1;
             }
@@ -577,13 +575,11 @@ class ActionComm extends CommonObject
             {
             	$this->db->commit();
             	return $this->id;
-            }
-            else {
+            } else {
                 $this->db->rollback();
                 return -1;
             }
-        }
-        else {
+        } else {
             $this->db->rollback();
             $this->error = $this->db->lasterror();
             return -1;
@@ -647,8 +643,7 @@ class ActionComm extends CommonObject
         {
             $this->db->commit();
             return $this->id;
-        }
-        else {
+        } else {
             $this->db->rollback();
             return -1;
         }
@@ -762,8 +757,7 @@ class ActionComm extends CommonObject
                 $this->fetchResources();
             }
             $this->db->free($resql);
-        }
-        else {
+        } else {
             $this->error = $this->db->lasterror();
             return -1;
         }
@@ -808,8 +802,7 @@ class ActionComm extends CommonObject
             }
 
         	return 1;
-		}
-		else {
+		} else {
 			dol_print_error($this->db);
 			return -1;
 		}
@@ -862,8 +855,7 @@ class ActionComm extends CommonObject
             }
 
             return 1;
-        }
-        else {
+        } else {
             dol_print_error($this->db);
             return -1;
         }
@@ -945,13 +937,11 @@ class ActionComm extends CommonObject
             {
                 $this->db->commit();
                 return 1;
-            }
-            else {
+            } else {
                 $this->db->rollback();
                 return -2;
             }
-        }
-        else {
+        } else {
             $this->db->rollback();
             $this->error = $this->db->lasterror();
             return -1;
@@ -1097,14 +1087,12 @@ class ActionComm extends CommonObject
             {
                 $this->db->commit();
                 return 1;
-            }
-            else {
+            } else {
                 $this->db->rollback();
                 dol_syslog(get_class($this)."::update ".join(',', $this->errors), LOG_ERR);
                 return -2;
             }
-        }
-        else {
+        } else {
             $this->db->rollback();
             $this->error = $this->db->lasterror();
             return -1;
@@ -1163,8 +1151,7 @@ class ActionComm extends CommonObject
             }
             $db->free($resql);
             return $resarray;
-        }
-        else {
+        } else {
             return $db->lasterror();
         }
     }
@@ -1223,8 +1210,7 @@ class ActionComm extends CommonObject
     		$this->db->free($resql);
     		if (empty($load_state_board)) return $response;
     		else return 1;
-    	}
-    	else {
+    	} else {
     		dol_print_error($this->db);
     		$this->error = $this->db->error();
     		return -1;
@@ -1274,8 +1260,7 @@ class ActionComm extends CommonObject
                 if (!empty($obj->fk_user_mod)) $this->date_modification = $this->db->jdate($obj->datem);
             }
             $this->db->free($result);
-        }
-        else {
+        } else {
             dol_print_error($this->db);
         }
     }
@@ -1404,8 +1389,7 @@ class ActionComm extends CommonObject
 		    $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
 		    $linkclose = ($hookmanager->resPrint ? $hookmanager->resPrint : $linkclose);
 		    */
-		}
-		else $linkclose .= ' class="'.$classname.'"';
+		} else $linkclose .= ' class="'.$classname.'"';
 
 		$url = '';
 		if ($option == 'birthday')
@@ -1435,8 +1419,7 @@ class ActionComm extends CommonObject
             $libelle = $label;
             if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) $libelle = $labeltype;
             $libelleshort = '';
-        }
-        else {
+        } else {
             $libelle = (empty($this->libelle) ? $label : $this->libelle.(($label && $label != $this->libelle) ? ' '.$label : ''));
             if (!empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($libelle)) $libelle = $labeltype;
             if ($maxlength < 0) $libelleshort = $this->ref;
@@ -1677,8 +1660,7 @@ class ActionComm extends CommonObject
                     {
                         $dateend = $this->db->jdate($obj->datep2)
                                  - (empty($conf->global->AGENDA_EXPORT_FIX_TZ) ? 0 : ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600));
-                    }
-                    else {
+                    } else {
                         // use start date as fall-back to avoid import erros on empty end date
                         $dateend = $datestart;
                     }
@@ -1734,8 +1716,7 @@ class ActionComm extends CommonObject
 				{
 					$eventarray = $hookmanager->resArray;
 				}
-            }
-            else {
+            } else {
                 $this->error = $this->db->lasterror();
                 return -1;
             }
@@ -1768,15 +1749,13 @@ class ActionComm extends CommonObject
 
                             $timestampStart = dol_stringtotime($obj->date_start." 00:00:00", 0);
                             $timestampEnd   = dol_stringtotime($obj->date_end." 12:00:00", 0);
-                        }
-                        elseif ($obj->halfday == 1)
+                        } elseif ($obj->halfday == 1)
                         {
                             $event['fulldayevent'] = false;
 
                             $timestampStart = dol_stringtotime($obj->date_start." 12:00:00", 0);
                             $timestampEnd   = dol_stringtotime($obj->date_end." 23:59:59", 0);
-                        }
-                        else {
+                        } else {
                             $event['fulldayevent'] = true;
 
                             $timestampStart = dol_stringtotime($obj->date_start." 00:00:00", 0);
@@ -1810,8 +1789,7 @@ class ActionComm extends CommonObject
                         {
                             // 2 = leave wait for approval
                             $event['summary'] = $title." - ".$obj->lastname." (wait for approval)";
-                        }
-                        else {
+                        } else {
                             // 3 = leave approved
                             $event['summary'] = $title." - ".$obj->lastname;
                         }
@@ -1836,8 +1814,7 @@ class ActionComm extends CommonObject
                 $title = 'Dolibarr actions '.$mysoc->name.' - '.$more;
                 $desc = $more;
                 $desc .= ' ('.$mysoc->name.' - built by Dolibarr)';
-            }
-            else {
+            } else {
                 $title = 'Dolibarr actions '.$mysoc->name;
                 $desc = $langs->transnoentities('ListOfActions');
                 $desc .= ' ('.$mysoc->name.' - built by Dolibarr)';
@@ -1861,8 +1838,7 @@ class ActionComm extends CommonObject
                     dol_delete_file($outputfiletmp, 0, 1);
                     $result = -1;
                 }
-            }
-            else {
+            } else {
                 dol_syslog(get_class($this)."::build_exportfile build_xxxfile function fails to for format=".$format." outputfiletmp=".$outputfile, LOG_ERR);
                 dol_delete_file($outputfiletmp, 0, 1);
                 $langs->load("errors");

+ 5 - 10
htdocs/comm/action/class/actioncommreminder.class.php

@@ -200,28 +200,23 @@ class ActionCommReminder extends CommonObject
 		{
 			if ($status == 1) return $langs->trans('Done');
 			elseif ($status == 0) return $langs->trans('ToDo');
-		}
-		elseif ($mode == 2)
+		} elseif ($mode == 2)
 		{
 			if ($status == 1) return img_picto($langs->trans('Done'), 'statut4').' '.$langs->trans('Done');
 			elseif ($status == 0) return img_picto($langs->trans('ToDo'), 'statut5').' '.$langs->trans('ToDo');
-		}
-		elseif ($mode == 3)
+		} elseif ($mode == 3)
 		{
 			if ($status == 1) return img_picto($langs->trans('Done'), 'statut4');
 			elseif ($status == 0) return img_picto($langs->trans('ToDo'), 'statut5');
-		}
-		elseif ($mode == 4)
+		} elseif ($mode == 4)
 		{
 			if ($status == 1) return img_picto($langs->trans('Done'), 'statut4').' '.$langs->trans('Done');
 			elseif ($status == 0) return img_picto($langs->trans('ToDo'), 'statut5').' '.$langs->trans('ToDo');
-		}
-		elseif ($mode == 5)
+		} elseif ($mode == 5)
 		{
 			if ($status == 1) return $langs->trans('Done').' '.img_picto($langs->trans('Done'), 'statut4');
 			elseif ($status == 0) return $langs->trans('ToDo').' '.img_picto($langs->trans('ToDo'), 'statut5');
-		}
-		elseif ($mode == 6)
+		} elseif ($mode == 6)
 		{
 			if ($status == 1) return $langs->trans('Done').' '.img_picto($langs->trans('Done'), 'statut4');
 			elseif ($status == 0) return $langs->trans('ToDo').' '.img_picto($langs->trans('ToDo'), 'statut5');

+ 1 - 2
htdocs/comm/action/class/api_agendaevents.class.php

@@ -175,8 +175,7 @@ class AgendaEvents extends DolibarrApi
                 }
                 $i++;
             }
-        }
-        else {
+        } else {
             throw new RestException(503, 'Error when retrieve Agenda Event list : '.$db->lasterror());
         }
         if (!count($obj_ret)) {

+ 3 - 6
htdocs/comm/action/class/cactioncomm.class.php

@@ -104,13 +104,11 @@ class CActionComm
 
                 $this->db->free($resql);
                 return 1;
-            }
-            else {
+            } else {
                 $this->db->free($resql);
                 return 0;
             }
-        }
-        else {
+        } else {
             $this->error = $this->db->error();
             return -1;
         }
@@ -206,8 +204,7 @@ class CActionComm
             if ($idorcode == 'id') $this->liste_array = $repid;
             if ($idorcode == 'code') $this->liste_array = $repcode;
             return $this->liste_array;
-        }
-        else {
+        } else {
             $this->error = $this->db->lasterror();
             return -1;
         }

+ 4 - 8
htdocs/comm/action/class/ical.class.php

@@ -179,15 +179,13 @@ class ICal
 								$tmpkey = '';
 								$tmpvalue = '';
 							}
-						}
-                    	elseif (preg_match('/^ENCODING=QUOTED-PRINTABLE:/i', $value))
+						} elseif (preg_match('/^ENCODING=QUOTED-PRINTABLE:/i', $value))
                     	{
                     		if (preg_match('/=$/', $value))
                     		{
                     			$tmpkey = $key;
                     			$tmpvalue = $tmpvalue.preg_replace('/=$/', "", $value); // We must wait to have next line to have complete message
-                    		}
-                    		else {
+                    		} else {
                     			$value = quotedPrintDecode(preg_replace('/^ENCODING=QUOTED-PRINTABLE:/i', '', $tmpvalue.$value));
                     		}
                     	}                    	//$value=quotedPrintDecode($tmpvalue.$value);
@@ -235,8 +233,7 @@ class ICal
         	if (stristr($key, "DTSTART;VALUE=DATE") || stristr($key, "DTEND;VALUE=DATE"))
         	{
         		list($key, $value) = array($key, $value);
-        	}
-        	else {
+        	} else {
         		list($key, $value) = $this->ical_dt_date($key, $value);
         	}
         }
@@ -375,8 +372,7 @@ class ICal
         {
             usort($temp, array(&$this, "ical_dtstart_compare"));
             return $temp;
-        }
-        else {
+        } else {
             return false;
         }
     }

+ 2 - 4
htdocs/comm/action/document.php

@@ -215,8 +215,7 @@ if ($object->id > 0)
 			}
 		}
 		$_SESSION['assignedtouser'] = json_encode($listofuserid);
-	}
-	else {
+	} else {
 		if (!empty($_SESSION['assignedtouser']))
 		{
 			$listofuserid = json_decode($_SESSION['assignedtouser'], true);
@@ -262,8 +261,7 @@ if ($object->id > 0)
 	$permission = $user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create;
 	$param = '&id='.$object->id;
 	include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
-}
-else {
+} else {
 	print $langs->trans("ErrorUnknown");
 }
 

+ 45 - 91
htdocs/comm/action/index.php

@@ -95,8 +95,7 @@ if (GETPOST('search_actioncode', 'array'))
 {
     $actioncode = GETPOST('search_actioncode', 'array', 3);
     if (!count($actioncode)) $actioncode = '0';
-}
-else {
+} else {
 	$actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE));
 }
 if ($actioncode == '' && empty($actioncodearray)) $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE);
@@ -459,13 +458,11 @@ if (!empty($conf->use_javascript_ajax))	// If javascript on
     if (empty($reshook))
     {
 		$s .= $hookmanager->resPrint;
-    }
-    elseif ($reshook > 1)
+    } elseif ($reshook > 1)
 	{
     	$s = $hookmanager->resPrint;
     }
-}
-else // If javascript off
+} else // If javascript off
 {
 	$newparam = $param; // newparam is for birthday links
     $newparam = preg_replace('/showbirthday=[0-1]/i', 'showbirthday='.(empty($showbirthday) ? 1 : 0), $newparam);
@@ -515,16 +512,14 @@ if (!empty($actioncode))
             if ($actioncode == 'AC_OTH') $sql .= " AND ca.type != 'systemauto'";
             if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND ca.type = 'systemauto'";
         }
-    }
-    else {
+    } else {
         if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'";
         elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'";
         else {
             if (is_array($actioncode))
             {
 	        	$sql .= " AND ca.code IN ('".implode("','", $actioncode)."')";
-            }
-            else {
+            } else {
 	        	$sql .= " AND ca.code IN ('".implode("','", explode(',', $actioncode))."')";
             }
         }
@@ -548,8 +543,7 @@ if ($action == 'show_day')
     $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'";
     $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')";
     $sql .= ')';
-}
-else {
+} else {
     // To limit array
     $sql .= " AND (";
     $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'"; // Start 7 days before
@@ -645,8 +639,7 @@ if ($resql)
         $event->date_start_in_calendar >= $lastdaytoshow)
         {
             // This record is out of visible range
-        }
-        else {
+        } else {
             if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar = $firstdaytoshow;
             if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar = ($lastdaytoshow - 1);
 
@@ -667,16 +660,14 @@ if ($resql)
 
                 $daykey += 60 * 60 * 24;
                 if ($daykey > $event->date_end_in_calendar) $loop = false;
-            }
-            while ($loop);
+            } while ($loop);
 
             //print 'Event '.$i.' id='.$event->id.' (start='.dol_print_date($event->datep).'-end='.dol_print_date($event->datef);
             //print ' startincalendar='.dol_print_date($event->date_start_in_calendar).'-endincalendar='.dol_print_date($event->date_end_in_calendar).') was added in '.$j.' different index key of array<br>';
         }
         $i++;
     }
-}
-else {
+} else {
     dol_print_error($db);
 }
 
@@ -692,8 +683,7 @@ if ($showbirthday)
     {
         $sql .= ' AND MONTH(birthday) = '.$month;
         $sql .= ' AND DAY(birthday) = '.$day;
-    }
-    else {
+    } else {
         $sql .= ' AND MONTH(birthday) = '.$month;
     }
     $sql .= ' ORDER BY birthday';
@@ -735,12 +725,10 @@ if ($showbirthday)
                 $eventarray[$daykey][] = $event;
                 $daykey += 60 * 60 * 24;
                 if ($daykey > $event->date_end_in_calendar) $loop = false;
-            }
-            while ($loop);
+            } while ($loop);
             $i++;
         }
-    }
-    else {
+    } else {
         dol_print_error($db);
     }
 }
@@ -757,12 +745,10 @@ if ($conf->global->AGENDA_SHOW_HOLIDAYS)
     {
         // Request only leaves for the current selected day
         $sql .= " AND '".$year."-".$month."-".$day."' BETWEEN x.date_debut AND x.date_fin";
-    }
-    elseif ($action == 'show_week')
+    } elseif ($action == 'show_week')
     {
         // TODO: Add filter to reduce database request
-    }
-    elseif ($action == 'show_month')
+    } elseif ($action == 'show_month')
     {
         // TODO: Add filter to reduce database request
     }
@@ -795,8 +781,7 @@ if ($conf->global->AGENDA_SHOW_HOLIDAYS)
             {
                 // Show no symbol for leave with state "leave approved"
                 $event->percentage = -1;
-            }
-            elseif ($obj->status == 2)
+            } elseif ($obj->status == 2)
             {
                 // Show TO-DO symbol for leave with state "leave wait for approval"
                 $event->percentage = 0;
@@ -805,12 +790,10 @@ if ($conf->global->AGENDA_SHOW_HOLIDAYS)
             if ($obj->halfday == 1)
             {
                 $event->label = $obj->lastname.' ('.$langs->trans("Morning").')';
-            }
-            elseif ($obj->halfday == -1)
+            } elseif ($obj->halfday == -1)
             {
                 $event->label = $obj->lastname.' ('.$langs->trans("Afternoon").')';
-            }
-            else {
+            } else {
                 $event->label = $obj->lastname;
             }
 
@@ -823,9 +806,7 @@ if ($conf->global->AGENDA_SHOW_HOLIDAYS)
                 $eventarray[$daykey][] = $event;
 
                 $daykey += 60 * 60 * 24;
-            }
-
-            while ($daykey <= $event->date_end_in_calendar);
+            } while ($daykey <= $event->date_end_in_calendar);
 
             $i++;
         }
@@ -867,8 +848,7 @@ if (count($listofextcals))
                     {
                         $datecurstart = dol_stringtotime($icalevent['DTSTART;VALUE=DATE'], 1);
                         $datecurend = dol_stringtotime($icalevent['DTEND;VALUE=DATE'], 1) - 1; // We remove one second to get last second of day
-                    }
-                    elseif (is_array($icalevent['DTSTART']) && !empty($icalevent['DTSTART']['unixtime']))
+                    } elseif (is_array($icalevent['DTSTART']) && !empty($icalevent['DTSTART']['unixtime']))
                     {
                         $datecurstart = $icalevent['DTSTART']['unixtime'];
                         $datecurend = $icalevent['DTEND']['unixtime'];
@@ -888,8 +868,7 @@ if (count($listofextcals))
                         }
                         // datecurstart and datecurend are now GMT date
                         //var_dump($datecurstart); var_dump($datecurend); exit;
-                    }
-                    else {
+                    } else {
                         // Not a recongized record
                         dol_syslog("Found a not recognized repeatable record with unknown date start", LOG_ERR);
                         continue;
@@ -913,8 +892,7 @@ if (count($listofextcals))
                             {
                                 $newevent['DTSTART;VALUE=DATE'] = dol_print_date($datecurstart, '%Y%m%d');
                                 $newevent['DTEND;VALUE=DATE'] = dol_print_date($datecurend + 1, '%Y%m%d');
-                            }
-                            else {
+                            } else {
                                 $newevent['DTSTART'] = $datecurstart;
                                 $newevent['DTEND'] = $datecurend;
                             }
@@ -932,13 +910,11 @@ if (count($listofextcals))
                         {
                             $datecurstart = dol_time_plus_duree($datecurstart, $interval, 'w');
                             $datecurend = dol_time_plus_duree($datecurend, $interval, 'w');
-                        }
-                        elseif ($icalevent['RRULE']['FREQ'] == 'MONTHLY')
+                        } elseif ($icalevent['RRULE']['FREQ'] == 'MONTHLY')
                         {
                             $datecurstart = dol_time_plus_duree($datecurstart, $interval, 'm');
                             $datecurend = dol_time_plus_duree($datecurend, $interval, 'm');
-                        }
-                        elseif ($icalevent['RRULE']['FREQ'] == 'YEARLY')
+                        } elseif ($icalevent['RRULE']['FREQ'] == 'YEARLY')
                         {
                             $datecurstart = dol_time_plus_duree($datecurstart, $interval, 'y');
                             $datecurend = dol_time_plus_duree($datecurend, $interval, 'y');
@@ -975,8 +951,7 @@ if (count($listofextcals))
                     //print dol_print_date($dateend,'dayhour','gmt');
                     $event->fulldayevent = 1;
                     $addevent = true;
-                }
-                elseif (!is_array($icalevent['DTSTART'])) // not fullday event (DTSTART is not array. It is a value like '19700101T000000Z' for 00:00 in greenwitch)
+                } elseif (!is_array($icalevent['DTSTART'])) // not fullday event (DTSTART is not array. It is a value like '19700101T000000Z' for 00:00 in greenwitch)
                 {
                     $datestart = $icalevent['DTSTART'];
                     $dateend = $icalevent['DTEND'];
@@ -987,8 +962,7 @@ if (count($listofextcals))
                     $addevent = true;
                     //var_dump($offsettz);
                     //var_dump(dol_print_date($datestart, 'dayhour', 'gmt'));
-                }
-                elseif (isset($icalevent['DTSTART']['unixtime']))	// File contains a local timezone + a TZ (for example when using bluemind)
+                } elseif (isset($icalevent['DTSTART']['unixtime']))	// File contains a local timezone + a TZ (for example when using bluemind)
                 {
                     $datestart = $icalevent['DTSTART']['unixtime'];
                     $dateend = $icalevent['DTEND']['unixtime'];
@@ -1050,8 +1024,7 @@ if (count($listofextcals))
                         //print 'x'.$datestart.'-'.$dateend;exit;
                         //print 'x'.$datestart.'-'.$dateend;exit;
                         // This record is out of visible range
-                    }
-                    else {
+                    } else {
                         if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar = $firstdaytoshow;
                         if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar = ($lastdaytoshow - 1);
 
@@ -1071,8 +1044,7 @@ if (count($listofextcals))
                             $eventarray[$daykey][] = $event;
                             $daykey += 60 * 60 * 24; $daykeygmt += 60 * 60 * 24; // Add one day
                             if (($event->fulldayevent ? $daykeygmt : $daykey) > $event->date_end_in_calendar) $loop = false;
-                        }
-                        while ($loop);
+                        } while ($loop);
                     }
                 }
             }
@@ -1141,8 +1113,7 @@ if (empty($action) || $action == 'show_month')      // View by month
         {
             $labelshort = array(0=>'SundayMin', 1=>'MondayMin', 2=>'TuesdayMin', 3=>'WednesdayMin', 4=>'ThursdayMin', 5=>'FridayMin', 6=>'SaturdayMin');
             print $langs->trans($labelshort[$numdayinweek]);
-        }
-        else print $langs->trans("Day".$numdayinweek);
+        } else print $langs->trans("Day".$numdayinweek);
         print '  </td>'."\n";
         $i++;
     }
@@ -1200,8 +1171,7 @@ if (empty($action) || $action == 'show_month')      // View by month
 	print '<input type="hidden" name="actionmove" value="mupdate">';
 	print '<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($_SERVER['PHP_SELF']).'?'.dol_escape_htmltag($_SERVER['QUERY_STRING']).'">';
 	print '<input type="hidden" name="newdate" id="newdate">';
-}
-elseif ($action == 'show_week') // View by week
+} elseif ($action == 'show_week') // View by week
 {
     $newparam = $param; // newparam is for birthday links
     $newparam = preg_replace('/showbirthday=/i', 'showbirthday_=', $newparam); // To avoid replacement when replace day= is done
@@ -1255,8 +1225,7 @@ elseif ($action == 'show_week') // View by week
     echo '<input type="hidden" name="actionmove" value="mupdate">';
     echo '<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($_SERVER['PHP_SELF']).'?'.dol_escape_htmltag($_SERVER['QUERY_STRING']).'">';
     echo '<input type="hidden" name="newdate" id="newdate">';
-}
-else // View by day
+} else // View by day
 {
     $newparam = $param; // newparam is for birthday links
     $newparam = preg_replace('/action=show_month&?/i', '', $newparam);
@@ -1330,8 +1299,7 @@ else // View by day
 		show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 1);
 
 		print '</div>';
-    }
-    else {
+    } else {
     	print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
 
     	show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 0);
@@ -1452,8 +1420,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
 
 	                    // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event)
 	                    if (!empty($cacheusers[$event->userownerid]->color)) $color = $cacheusers[$event->userownerid]->color;
-                    }
-                    elseif ($event->type_code == 'ICALEVENT')      // Event come from external ical file
+                    } elseif ($event->type_code == 'ICALEVENT')      // Event come from external ical file
                     {
                     	$numical++;
                     	if (!empty($event->icalname)) {
@@ -1465,12 +1432,10 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
 
                     	$color = ($event->icalcolor ? $event->icalcolor : -1);
                     	$cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other');
-                    }
-                    elseif ($event->type_code == 'BIRTHDAY')
+                    } elseif ($event->type_code == 'BIRTHDAY')
                     {
                     	$numbirthday++; $colorindex = 2; $cssclass = 'family_birthday unmovable'; $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
-                    }
-                    else {
+                    } else {
                     	$numother++;
                     	$color = ($event->icalcolor ? $event->icalcolor : -1);
                     	$cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other');
@@ -1494,8 +1459,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
                     	if (isset($colorindexused[$idusertouse]))
                     	{
                     		$colorindex = $colorindexused[$idusertouse]; // Color already assigned to this user
-                    	}
-                    	else {
+                    	} else {
                    			$colorindex = $nextindextouse;
                    			$colorindexused[$idusertouse] = $colorindex;
                     		if (!empty($theme_datacolor[$nextindextouse + 1])) $nextindextouse++; // Prepare to use next color
@@ -1510,8 +1474,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
                     if ($event->type_code == 'AC_OTH_AUTO')
                     {
                         $cssclass .= " unmovable";
-                    }
-                    elseif ($event->type_code == 'ICALEVENT')
+                    } elseif ($event->type_code == 'ICALEVENT')
                     {
                         $cssclass .= " unmovable";
                     } elseif ($event->date_end_in_calendar && date('Ymd', $event->date_start_in_calendar) != date('Ymd', $event->date_end_in_calendar)) {
@@ -1522,8 +1485,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
                         {
                             $cssclass .= " unmovable";
                         }
-                    }
-                    else {
+                    } else {
                         if ($user->rights->agenda->allactions->create ||
                             (($event->authorid == $user->id || $event->userownerid == $user->id) && $user->rights->agenda->myactions->create))
                         {
@@ -1557,8 +1519,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
                     if (empty($event->transparency) && empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY))
                     {
                     	print 'border: 2px solid #'.$colortouse.';';
-                    }
-                    else {
+                    } else {
                     	print 'background: #'.$colortouse.';';
                     	print 'background: -webkit-gradient(linear, left top, left bottom, from(#'.dol_color_minus($colortouse, -3).'), to(#'.dol_color_minus($colortouse, -1).'));';
                     }
@@ -1577,12 +1538,10 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
                     if ($event->type_code == 'BIRTHDAY') // It's a birthday
                     {
                         print $event->getNomUrl(1, $maxnbofchar, 'cal_event', 'birthday', 'contact');
-                    }
-					elseif ($event->type_code == 'HOLIDAY')
+                    } elseif ($event->type_code == 'HOLIDAY')
                     {
                         print $event->getNomUrl(1, $maxnbofchar, 'cal_event', 'holiday', 'user');
-                    }
-                    elseif ($event->type_code != 'BIRTHDAY' && $event->type_code != 'HOLIDAY')
+                    } elseif ($event->type_code != 'BIRTHDAY' && $event->type_code != 'HOLIDAY')
                     {
                         // Picto
                         if (empty($event->fulldayevent))
@@ -1625,8 +1584,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
                                 if ($tmpyearend == $annee && $tmpmonthend == $mois && $tmpdayend == $jour)
                                 $daterange .= dol_print_date($event->date_end_in_calendar, '%H:%M'); // Il faudrait utiliser ici tzuser, mais si on ne peut pas car qd on rentre un date dans fiche action, en input la conversion local->gmt se base sur le TZ server et non user
                             }
-                        }
-                        else {
+                        } else {
                             if ($showinfo)
                             {
                                 print $langs->trans("EventOnFullDay")."<br>\n";
@@ -1681,8 +1639,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
                                 $thirdparty = new Societe($db);
                                 $thirdparty->fetch($thirdparty_id);
                                 $cachethirdparties[$thirdparty_id] = $thirdparty;
-                            }
-                            else $thirdparty = $cachethirdparties[$thirdparty_id];
+                            } else $thirdparty = $cachethirdparties[$thirdparty_id];
                             if (!empty($thirdparty->id)) $linerelatedto .= $thirdparty->getNomUrl(1, '', 0);
                         }
                         if (!empty($contact_id) && $contact_id > 0)
@@ -1692,8 +1649,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
                                 $contact = new Contact($db);
                                 $contact->fetch($contact_id);
                                 $cachecontacts[$contact_id] = $contact;
-                            }
-                            else $contact = $cachecontacts[$contact_id];
+                            } else $contact = $cachecontacts[$contact_id];
                             if ($linerelatedto) $linerelatedto .= '&nbsp;';
                             if (!empty($contact->id)) $linerelatedto .= $contact->getNomUrl(1, '', 0);
                         }
@@ -1730,8 +1686,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
                     print '</td></tr></table>';
                     print '</div><!-- end event '.$i.' -->'."\n";
                     $i++;
-                }
-                else {
+                } else {
                 	print '<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action='.$action.'&maxprint=0&month='.$monthshown.'&year='.$year;
                     print ($status ? '&status='.$status : '').($filter ? '&filter='.$filter : '');
                     print ($filtert ? '&search_filtert='.$filtert : '');
@@ -1792,8 +1747,7 @@ function dol_color_minus($color, $minus, $minusunit = 16)
     	$newcolor[0] = dechex(max(min(hexdec($newcolor[0]) - $minus, 15), 0));
     	$newcolor[2] = dechex(max(min(hexdec($newcolor[2]) - $minus, 15), 0));
     	$newcolor[4] = dechex(max(min(hexdec($newcolor[4]) - $minus, 15), 0));
-	}
-	else {
+	} else {
 	    // Not yet implemented
 	}
 	return $newcolor;

+ 11 - 22
htdocs/comm/action/list.php

@@ -54,8 +54,7 @@ if (GETPOST('search_actioncode', 'array'))
 {
     $actioncode = GETPOST('search_actioncode', 'array', 3);
     if (!count($actioncode)) $actioncode = '0';
-}
-else {
+} else {
     $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE));
 }
 if ($actioncode == '' && empty($actioncodearray)) $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE);
@@ -282,16 +281,14 @@ if (!empty($actioncode))
             if ($actioncode == 'AC_OTH') $sql .= " AND c.type != 'systemauto'";
             if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND c.type = 'systemauto'";
         }
-    }
-    else {
+    } else {
         if ($actioncode == 'AC_NON_AUTO') $sql .= " AND c.type != 'systemauto'";
         elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND c.type = 'systemauto'";
         else {
             if (is_array($actioncode))
             {
                 $sql .= " AND c.code IN ('".implode("','", $actioncode)."')";
-            }
-            else {
+            } else {
                 $sql .= " AND c.code IN ('".implode("','", explode(',', $actioncode))."')";
             }
         }
@@ -413,8 +410,7 @@ if ($resql)
     if (empty($reshook))
     {
 		$s .= $hookmanager->resPrint;
-    }
-    elseif ($reshook > 1)
+    } elseif ($reshook > 1)
 	{
     	$s = $hookmanager->resPrint;
     }
@@ -564,8 +560,7 @@ if ($resql)
 			{
 				$userstatic->fetch($obj->fk_user_action);
 				print $userstatic->getNomUrl(-1);
-			}
-			else print '&nbsp;';
+			} else print '&nbsp;';
 			print '</td>';
 		}
 
@@ -580,8 +575,7 @@ if ($resql)
 			{
 				if ($actioncomm->type_picto) {
 					$imgpicto = img_picto('', $actioncomm->type_picto);
-				}
-				else {
+				} else {
 					if ($actioncomm->type_code == 'AC_RDV')         $imgpicto = img_picto('', 'object_group', '', false, 0, 0, '', 'paddingright').' ';
 					elseif ($actioncomm->type_code == 'AC_TEL')     $imgpicto = img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright').' ';
 					elseif ($actioncomm->type_code == 'AC_FAX')     $imgpicto = img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright').' ';
@@ -649,8 +643,7 @@ if ($resql)
 				$societestatic->email = $obj->socemail;
 
 				print $societestatic->getNomUrl(1, '', 28);
-			}
-			else print '&nbsp;';
+			} else print '&nbsp;';
 			print '</td>';
 		}
 
@@ -672,8 +665,7 @@ if ($resql)
                             $contactListCache[$socpeopleassigned['id']] = $contact->getNomUrl(1, '', 0);
                             $contactList[] = $contact->getNomUrl(1, '', 0);
                         }
-                    }
-                    else {
+                    } else {
                         // use cache
                         $contactList[] = $contactListCache[$socpeopleassigned['id']];
                     }
@@ -681,8 +673,7 @@ if ($resql)
                 if (!empty($contactList)) {
                     print implode(', ', $contactList);
                 }
-            }
-            elseif ($obj->fk_contact > 0) //keep for retrocompatibility with faraway event
+            } elseif ($obj->fk_contact > 0) //keep for retrocompatibility with faraway event
 			{
 				$contactstatic->id = $obj->fk_contact;
 				$contactstatic->email = $obj->email;
@@ -693,8 +684,7 @@ if ($resql)
 				$contactstatic->phone_perso = $obj->phone_perso;
 				$contactstatic->country_id = $obj->country_id;
 				print $contactstatic->getNomUrl(1, '', 0);
-			}
-			else {
+			} else {
 				print "&nbsp;";
 			}
 			print '</td>';
@@ -744,8 +734,7 @@ if ($resql)
 	print '</form>';
 
 	$db->free($resql);
-}
-else {
+} else {
 	dol_print_error($db);
 }
 

+ 15 - 30
htdocs/comm/action/pertype.php

@@ -93,8 +93,7 @@ if (GETPOST('actioncode', 'array'))
 {
     $actioncode = GETPOST('actioncode', 'array', 3);
     if (!count($actioncode)) $actioncode = '0';
-}
-else {
+} else {
     $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode", "alpha") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE));
 }
 if ($actioncode == '' && empty($actioncodearray)) $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE);
@@ -328,8 +327,7 @@ if ($conf->use_javascript_ajax)
 	    if (empty($reshook))
 	    {
 			$s .= $hookmanager->resPrint;
-	    }
-	    elseif ($reshook > 1)
+	    } elseif ($reshook > 1)
 		{
 	    	$s = $hookmanager->resPrint;
 	    }
@@ -375,8 +373,7 @@ if (!empty($actioncode))
             if ($actioncode == 'AC_OTH') $sql .= " AND ca.type != 'systemauto'";
             if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND ca.type = 'systemauto'";
         }
-    }
-    else {
+    } else {
         if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'";
         elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'";
         else {
@@ -402,8 +399,7 @@ if ($action == 'show_day')
     $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'";
     $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')";
     $sql .= ')';
-}
-else {
+} else {
     // To limit array
     $sql .= " AND (";
     $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, 1, 1, $year) - (60 * 60 * 24 * 7))."'"; // Start 7 days before
@@ -485,8 +481,7 @@ if ($resql)
         	$event->date_start_in_calendar = $datep;
         	if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2;
         	else $event->date_end_in_calendar = $datep;
-        }
-        else {
+        } else {
         	$event->date_start_in_calendar = $datep;
         	if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2;
         	else $event->date_end_in_calendar = $datep;
@@ -503,8 +498,7 @@ if ($resql)
         {
             // This record is out of visible range
         	unset($event);
-        }
-        else {
+        } else {
 			//print $i.' - '.dol_print_date($this->date_start_in_calendar, 'dayhour').' - '.dol_print_date($this->date_end_in_calendar, 'dayhour').'<br>'."\n";
 			$event->fetch_userassigned(); // This load $event->userassigned
 
@@ -528,16 +522,14 @@ if ($resql)
 
                 $daykey += 60 * 60 * 24;
                 if ($daykey > $event->date_end_in_calendar) $loop = false;
-            }
-            while ($loop);
+            } while ($loop);
 
             //print 'Event '.$i.' id='.$event->id.' (start='.dol_print_date($event->datep).'-end='.dol_print_date($event->datef);
             //print ' startincalendar='.dol_print_date($event->date_start_in_calendar).'-endincalendar='.dol_print_date($event->date_end_in_calendar).') was added in '.$j.' different index key of array<br>';
         }
         $i++;
     }
-}
-else {
+} else {
     dol_print_error($db);
 }
 
@@ -799,8 +791,7 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s
 				{
 					$nummytasks++; $cssclass = 'family_mytasks';
 					if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) $color = $event->type_color;
-				}
-				elseif ($event->type_code == 'ICALEVENT')
+				} elseif ($event->type_code == 'ICALEVENT')
 				{
 					$numical++;
 					if (!empty($event->icalname))
@@ -813,12 +804,10 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s
 
 					$color = $event->icalcolor;
 					$cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other unsortable');
-				}
-				elseif ($event->type_code == 'BIRTHDAY')
+				} elseif ($event->type_code == 'BIRTHDAY')
 				{
 					$numbirthday++; $colorindex = 2; $cssclass = 'family_birthday unsortable'; $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
-				}
-				else {
+				} else {
 					$numother++; $cssclass = 'family_other';
 					if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) $color = $event->type_color;
 				}
@@ -830,8 +819,7 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s
 					if (isset($colorindexused[$idusertouse]))
 					{
 						$colorindex = $colorindexused[$idusertouse]; // Color already assigned to this user
-					}
-					else {
+					} else {
 						$colorindex = $nextindextouse;
 						$colorindexused[$idusertouse] = $colorindex;
 						if (!empty($theme_datacolor[$nextindextouse + 1])) $nextindextouse++; // Prepare to use next color
@@ -949,8 +937,7 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s
 								$cases2[$h][$event->id]['string'] .= ', '.$cachecontacts[$event->contactid]->getFullName($langs);
 							}
 						}
-					}
-					else {
+					} else {
 						$busy = $event->transparency;
 						$cases1[$h][$event->id]['busy'] = $busy;
 						$cases2[$h][$event->id]['busy'] = $busy;
@@ -1013,8 +1000,7 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s
 			$title1 = $langs->trans("Ref").' '.$ids1.($title1 ? ' - '.$title1 : '');
 			if ($output[0]['string']) $title1 .= ($title1 ? ' - ' : '').$output[0]['string'];
 			if ($output[0]['color']) $color1 = $output[0]['color'];
-		}
-		elseif (count($cases1[$h]) > 1)
+		} elseif (count($cases1[$h]) > 1)
 		{
 			$title1 = $langs->trans("Ref").' '.$ids1.($title1 ? ' - '.$title1 : '');
 			$color1 = '222222';
@@ -1026,8 +1012,7 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s
 			$title2 = $langs->trans("Ref").' '.$ids2.($title2 ? ' - '.$title2 : '');
 			if ($output[0]['string']) $title2 .= ($title2 ? ' - ' : '').$output[0]['string'];
 			if ($output[0]['color']) $color2 = $output[0]['color'];
-		}
-		elseif (count($cases2[$h]) > 1)
+		} elseif (count($cases2[$h]) > 1)
 		{
 			$title2 = $langs->trans("Ref").' '.$ids2.($title2 ? ' - '.$title2 : '');
 			$color2 = '222222';

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