From 3767ab437e6ba5cc126977ac5419ef818c4b5819 Mon Sep 17 00:00:00 2001
From: philippe grand <philippe.grand@atoo-net.com>
Date: Fri, 23 Oct 2015 12:58:30 +0200
Subject: [PATCH] [Qual] Uniformize code

---
 htdocs/accountancy/bookkeeping/card.php       | 26 +++++-----
 htdocs/accountancy/bookkeeping/list.php       |  4 +-
 htdocs/accountancy/customer/card.php          |  2 +-
 htdocs/accountancy/customer/index.php         |  4 +-
 htdocs/accountancy/customer/lines.php         |  6 +--
 htdocs/accountancy/journal/bankjournal.php    |  6 +--
 .../accountancy/journal/purchasesjournal.php  |  8 +--
 htdocs/accountancy/journal/sellsjournal.php   |  8 +--
 htdocs/accountancy/supplier/card.php          |  2 +-
 htdocs/accountancy/supplier/index.php         |  4 +-
 htdocs/accountancy/supplier/lines.php         |  6 +--
 htdocs/adherents/admin/adherent.php           |  6 +--
 htdocs/adherents/admin/public.php             |  4 +-
 htdocs/adherents/card.php                     | 50 +++++++++----------
 htdocs/adherents/card_subscriptions.php       |  6 +--
 htdocs/adherents/ldap.php                     |  4 +-
 htdocs/admin/agenda.php                       |  4 +-
 htdocs/admin/agenda_extsites.php              |  6 +--
 htdocs/admin/agenda_xcal.php                  |  4 +-
 htdocs/admin/askpricesupplier.php             | 28 +++++------
 htdocs/admin/bank.php                         |  4 +-
 htdocs/admin/barcode.php                      |  8 +--
 htdocs/admin/boxes.php                        |  4 +-
 htdocs/admin/clicktodial.php                  |  4 +-
 htdocs/admin/commande.php                     | 34 ++++++-------
 htdocs/admin/company.php                      | 12 ++---
 htdocs/admin/compta.php                       |  6 +--
 htdocs/admin/const.php                        |  8 +--
 htdocs/admin/contract.php                     | 18 +++----
 htdocs/admin/dict.php                         | 18 +++----
 htdocs/admin/menus/edit.php                   | 14 +++---
 htdocs/admin/menus/index.php                  |  4 +-
 htdocs/admin/tools/dolibarr_export.php        |  4 +-
 htdocs/admin/tools/export.php                 | 10 ++--
 htdocs/admin/tools/update.php                 | 14 +++---
 35 files changed, 175 insertions(+), 175 deletions(-)

diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php
index d4c256dfbf2..0500ac4a0a7 100644
--- a/htdocs/accountancy/bookkeeping/card.php
+++ b/htdocs/accountancy/bookkeeping/card.php
@@ -52,7 +52,7 @@ if ($action == "confirm_update") {
     $error = 0;
 
     if ((floatval($debit)!=0.0) && (floatval($credit)!=0.0)) {
-        setEventMessage($langs->trans('ErrorDebitCredit'), 'errors');
+        setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors');
         $error ++;
     }
 
@@ -61,7 +61,7 @@ if ($action == "confirm_update") {
 
         $result = $book->fetch($id);
         if ($result < 0) {
-            setEventMessage($book->errors, 'errors');
+            setEventMessages($book->error, $book->errors, 'errors');
         } else {
             $book->numero_compte = $numero_compte;
             $book->code_tiers = $code_tiers;
@@ -80,9 +80,9 @@ if ($action == "confirm_update") {
 
             $result = $book->update();
             if ($result < 0) {
-                setEventMessage($book->errors, 'errors');
+                setEventMessages($book->error, $book->errors, 'errors');
             } else {
-                setEventMessage($langs->trans('Saved'), 'mesgs');
+                setEventMessages($langs->trans('Saved'), null, 'mesgs');
                 $action = '';
             }
         }
@@ -93,7 +93,7 @@ else if ($action == "add") {
     $error = 0;
 
     if ((intval($debit) != 0) && (intval($credit) != 0)) {
-        setEventMessage($langs->trans('ErrorDebitCredit'), 'errors');
+        setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors');
         $error ++;
     }
 
@@ -124,9 +124,9 @@ else if ($action == "add") {
 
         $result = $book->create_std($user);
         if ($result < 0) {
-            setEventMessage($book->errors, 'errors');
+            setEventMessages($book->error, $book->errors, 'errors');
         } else {
-            setEventMessage($langs->trans('Saved'), 'mesgs');
+            setEventMessages($langs->trans('Saved'), null, 'mesgs');
             $action = '';
         }
     }
@@ -140,11 +140,11 @@ else if ($action == "confirm_delete") {
     $piece_num = $book->piece_num;
 
     if ($result < 0) {
-        setEventMessage($book->errors, 'errors');
+        setEventMessages($book->error, $book->errors, 'errors');
     } else {
         $result = $book->delete($user);
         if ($result < 0) {
-            setEventMessage($book->errors, 'errors');
+            setEventMessages($book->error, $book->errors, 'errors');
         }
     }
     $action = '';
@@ -168,9 +168,9 @@ else if ($action == "confirm_create") {
 
     $result = $book->create_std($user);
     if ($result < 0) {
-        setEventMessage($book->errors, 'errors');
+        setEventMessages($book->error, $book->errors, 'errors');
     } else {
-        setEventMessage($langs->trans('Saved'), 'mesgs');
+        setEventMessages($langs->trans('Saved'), null, 'mesgs');
         $action = '';
         $piece_num = $book->piece_num;
     }
@@ -246,7 +246,7 @@ if ($action == 'create') {
     $book = new BookKeeping($db);
     $result = $book->fetch_per_mvt($piece_num);
     if ($result < 0) {
-        setEventMessage($book->errors, 'errors');
+        setEventMessages($book->error, $book->errors, 'errors');
     }
     if (! empty($book->piece_num)) {
 
@@ -277,7 +277,7 @@ if ($action == 'create') {
 
         $result = $book->fetch_all_per_mvt($piece_num);
         if ($result < 0) {
-            setEventMessage($book->errors, 'errors');
+            setEventMessages($book->error, $book->errors, 'errors');
         } else {
 
             print load_fiche_titre($langs->trans("ListeMvts"));
diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php
index d9b6d66b503..b9164329031 100644
--- a/htdocs/accountancy/bookkeeping/list.php
+++ b/htdocs/accountancy/bookkeeping/list.php
@@ -74,7 +74,7 @@ if ($action == 'delbookkeeping') {
 		$result = $object->delete_by_importkey($import_key);
 		Header("Location: list.php");
 		if ($result < 0) {
-			setEventMessage($object->errors, 'errors');
+			setEventMessages($object->error, $object->errors, 'errors');
 		}
 	}
 } // Export
@@ -86,7 +86,7 @@ else if ($action == 'export_csv') {
 	$object = new BookKeeping($db);
 	$result = $object->export_bookkeping('ebp');
 	if ($result < 0) {
-		setEventMessage($object->errors, 'errors');
+		setEventMessages($object->error, $object->errors, 'errors');
 	}
 	
 	foreach ( $object->linesexport as $line ) {
diff --git a/htdocs/accountancy/customer/card.php b/htdocs/accountancy/customer/card.php
index 09e8b24a8ea..a3e179c1701 100644
--- a/htdocs/accountancy/customer/card.php
+++ b/htdocs/accountancy/customer/card.php
@@ -54,7 +54,7 @@ if ($action == 'ventil' && $user->rights->accounting->ventilation->dispatch) {
 		dol_syslog("/accounting/customer/card.php sql=" . $sql, LOG_DEBUG);
 		$resql = $db->query($sql);
 		if (! $resql) {
-			setEventMessage($db->lasterror(), 'errors');
+			setEventMessages($db->lasterror(), null, 'errors');
 		}
 	} else {
 		header("Location: ./lines.php");
diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php
index ea37f237455..5a6de05691a 100644
--- a/htdocs/accountancy/customer/index.php
+++ b/htdocs/accountancy/customer/index.php
@@ -83,10 +83,10 @@ if ($action == 'validatehistory') {
 	if (! $resql1) {
 		$error ++;
 		$db->rollback();
-		setEventMessage($db->lasterror(), 'errors');
+		setEventMessages($db->lasterror(), null, 'errors');
 	} else {
 		$db->commit();
-		setEventMessage($langs->trans('Dispatched'), 'mesgs');
+		setEventMessages($langs->trans('Dispatched'), null, 'mesgs');
 	}
 }
 
diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php
index 01f34e700cc..a505c91c1c7 100644
--- a/htdocs/accountancy/customer/lines.php
+++ b/htdocs/accountancy/customer/lines.php
@@ -109,14 +109,14 @@ if (is_array($changeaccount) && count($changeaccount) > 0) {
 	$resql1 = $db->query($sql1);
 	if (! $resql1) {
 		$error ++;
-		setEventMessage($db->lasterror(), 'errors');
+		setEventMessages($db->lasterror(), null, 'errors');
 	}
 	if (! $error) {
 		$db->commit();
-		setEventMessage($langs->trans('Save'), 'mesgs');
+		setEventMessages($langs->trans('Save'), null, 'mesgs');
 	} else {
 		$db->rollback();
-		setEventMessage($db->lasterror(), 'errors');
+		setEventMessages($db->lasterror(), null, 'errors');
 	}
 }
 
diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php
index 01957fcedf5..cd0c5d06ce5 100644
--- a/htdocs/accountancy/journal/bankjournal.php
+++ b/htdocs/accountancy/journal/bankjournal.php
@@ -343,7 +343,7 @@ if ($action == 'writeBookKeeping')
 			$result = $bookkeeping->create();
 			if ($result < 0) {
 				$error ++;
-				setEventMessage($object->errors, 'errors');
+				setEventMessages($object->error, $object->errors, 'errors');
 			}
 		}
 		// Third party
@@ -420,13 +420,13 @@ if ($action == 'writeBookKeeping')
 			$result = $bookkeeping->create();
 			if ($result < 0) {
 				$error ++;
-				setEventMessage($object->errors, 'errors');
+				setEventMessages($object->error, $object->errors, 'errors');
 			}
 		}
 	}
 
 	if (empty($error)) {
-		setEventMessage($langs->trans("GeneralLedgerIsWritten"),'mesgs');
+		setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs');
 	}
 }
 // Export
diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php
index 28b2dc736b6..538edaa471d 100644
--- a/htdocs/accountancy/journal/purchasesjournal.php
+++ b/htdocs/accountancy/journal/purchasesjournal.php
@@ -185,7 +185,7 @@ if ($action == 'writebookkeeping') {
 			$result = $bookkeeping->create();
 			if ($result < 0) {
 				$error ++;
-				setEventMessage($object->errors, 'errors');
+				setEventMessages($object->error, $object->errors, 'errors');
 			}
 		}
 
@@ -215,7 +215,7 @@ if ($action == 'writebookkeeping') {
 					$result = $bookkeeping->create();
 					if ($result < 0) {
 						$error ++;
-						setEventMessage($object->errors, 'errors');
+						setEventMessages($object->error, $object->errors, 'errors');
 					}
 				}
 			}
@@ -246,14 +246,14 @@ if ($action == 'writebookkeeping') {
 				$result = $bookkeeping->create();
 				if ($result < 0) {
 					$error ++;
-					setEventMessage($object->errors, 'errors');
+					setEventMessages($object->error, $object->errors, 'errors');
 				}
 			}
 		}
 	}
 
 	if (empty($error)) {
-		setEventMessage($langs->trans("GeneralLedgerIsWritten"),'mesgs');
+		setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs');
 	}
 }
 
diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php
index 4437535738a..aaf3beea8a1 100644
--- a/htdocs/accountancy/journal/sellsjournal.php
+++ b/htdocs/accountancy/journal/sellsjournal.php
@@ -220,7 +220,7 @@ if ($action == 'writebookkeeping')
 			$result = $bookkeeping->create();
 			if ($result < 0) {
 				$error ++;
-				setEventMessage($object->errors, 'errors');
+				setEventMessages($object->error, $object->errors, 'errors');
 			}
 		}
 
@@ -250,7 +250,7 @@ if ($action == 'writebookkeeping')
 					$result = $bookkeeping->create();
 					if ($result < 0) {
 						$error ++;
-						setEventMessage($object->errors, 'errors');
+						setEventMessages($object->error, $object->errors, 'errors');
 					}
 				}
 			}
@@ -282,14 +282,14 @@ if ($action == 'writebookkeeping')
 				$result = $bookkeeping->create();
 				if ($result < 0) {
 					$error ++;
-					setEventMessage($object->errors, 'errors');
+					setEventMessages($object->error, $object->errors, 'errors');
 				}
 			}
 		}
 	}
 
 	if (empty($error)) {
-		setEventMessage($langs->trans("GeneralLedgerIsWritten"),'mesgs');
+		setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs');
 	}
 }
 
diff --git a/htdocs/accountancy/supplier/card.php b/htdocs/accountancy/supplier/card.php
index f0747c8d29c..61b225fbc16 100644
--- a/htdocs/accountancy/supplier/card.php
+++ b/htdocs/accountancy/supplier/card.php
@@ -55,7 +55,7 @@ if ($action == 'ventil' && $user->rights->accounting->ventilation->dispatch) {
 		dol_syslog('accountancy/supplier/card.php:: $sql=' . $sql);
 		$resql = $db->query($sql);
 		if (! $resql) {
-			setEventMessage($db->lasterror(), 'errors');
+			setEventMessages($db->lasterror(), null, 'errors');
 		}
 	} else {
 		header("Location: ./lines.php");
diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php
index 954eb60300c..ec18d8b1e23 100644
--- a/htdocs/accountancy/supplier/index.php
+++ b/htdocs/accountancy/supplier/index.php
@@ -79,10 +79,10 @@ if ($action == 'validatehistory') {
 	if (! $resql1) {
 		$error ++;
 		$db->rollback();
-		setEventMessage($db->lasterror(), 'errors');
+		setEventMessages($db->lasterror(), null, 'errors');
 	} else {
 		$db->commit();
-		setEventMessage($langs->trans('Dispatched'), 'mesgs');
+		setEventMessages($langs->trans('Dispatched'), null, 'mesgs');
 	}
 }
 
diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php
index f475e7046ad..e703bca6f2d 100644
--- a/htdocs/accountancy/supplier/lines.php
+++ b/htdocs/accountancy/supplier/lines.php
@@ -115,14 +115,14 @@ if (is_array($changeaccount) && count($changeaccount) > 0) {
 	$resql1 = $db->query($sql1);
 	if (! $resql1) {
 		$error ++;
-		setEventMessage($db->lasterror(), 'errors');
+		setEventMessages($db->lasterror(), null, 'errors');
 	}
 	if (! $error) {
 		$db->commit();
-		setEventMessage($langs->trans('Save'), 'mesgs');
+		setEventMessages($langs->trans('Save'), null, 'mesgs');
 	} else {
 		$db->rollback();
-		setEventMessage($db->lasterror(), 'errors');
+		setEventMessages($db->lasterror(), null, 'errors');
 	}
 }
 
diff --git a/htdocs/adherents/admin/adherent.php b/htdocs/adherents/admin/adherent.php
index 5827e1d22d7..8e265eb70f7 100644
--- a/htdocs/adherents/admin/adherent.php
+++ b/htdocs/adherents/admin/adherent.php
@@ -7,7 +7,7 @@
  * Copyright (C) 2005-2012 Regis Houssin        <regis.houssin@capnetworks.com>
  * Copyright (C) 2011-2012 Juanjo Menent		<jmenent@2byte.es>
  * Copyright (C) 2012      J. Fernando Lagrange <fernando@demo-tic.org>
- * Copyright (C) 2015       Jean-François Ferry		<jfefe@aternatik.fr>
+ * Copyright (C) 2015      Jean-François Ferry	<jfefe@aternatik.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -69,11 +69,11 @@ if ($action == 'update' || $action == 'add')
 
 	if (! $error)
 	{
-		setEventMessage($langs->trans("SetupSaved"));
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
 	}
 	else
 	{
-		setEventMessage($langs->trans("Error"), 'errors');
+		setEventMessages($langs->trans("Error"), null, 'errors');
 	}
 }
 
diff --git a/htdocs/adherents/admin/public.php b/htdocs/adherents/admin/public.php
index 58cb7bb2f41..6f5d1de5c87 100644
--- a/htdocs/adherents/admin/public.php
+++ b/htdocs/adherents/admin/public.php
@@ -60,11 +60,11 @@ if ($action == 'update')
 
  	if (! $error)
     {
-	    setEventMessage($langs->trans("SetupSaved"));
+	    setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
     }
     else
     {
-	    setEventMessage($langs->trans("Error"), 'errors');
+	    setEventMessages($langs->trans("Error"), null, 'errors');
     }
 }
 
diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php
index 355aedb3e68..f998c2f08a3 100644
--- a/htdocs/adherents/card.php
+++ b/htdocs/adherents/card.php
@@ -4,7 +4,7 @@
  * Copyright (C) 2004-2012 Laurent Destailleur  <eldy@users.sourceforge.net>
  * Copyright (C) 2005-2012 Regis Houssin        <regis.houssin@capnetworks.com>
  * Copyright (C) 2012      Marcos García        <marcosgdf@gmail.com>
- * Copyright (C) 2012-2013 Philippe Grand       <philippe.grand@atoo-net.com>
+ * Copyright (C) 2012-2015 Philippe Grand       <philippe.grand@atoo-net.com>
  * Copyright (C) 2015      Alexandre Spangaro   <aspangaro.dolibarr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -133,7 +133,7 @@ if (empty($reshook))
 			if ($userid != $user->id && $userid != $object->user_id)
 			{
 				$error++;
-				setEventMessage($langs->trans("ErrorUserPermissionAllowsToLinksToItselfOnly"), 'errors');
+				setEventMessages($langs->trans("ErrorUserPermissionAllowsToLinksToItselfOnly"), null, 'errors');
 			}
 		}
 
@@ -169,7 +169,7 @@ if (empty($reshook))
 						$thirdparty=new Societe($db);
 						$thirdparty->fetch($socid);
 						$error++;
-						setEventMessage($langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty",$othermember->getFullName($langs),$othermember->login,$thirdparty->name), 'errors');
+						setEventMessages($langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty",$othermember->getFullName($langs),$othermember->login,$thirdparty->name), null, 'errors');
 					}
 				}
 
@@ -195,12 +195,12 @@ if (empty($reshook))
 			if ($result < 0)
 			{
 				$langs->load("errors");
-				setEventMessage($langs->trans($nuser->error), 'errors');
+				setEventMessages($langs->trans($nuser->error), null, 'errors');
 			}
 		}
 		else
 		{
-			setEventMessage($object->error, 'errors');
+			setEventMessages($object->errors, $object->error, 'errors');
 		}
 	}
 
@@ -216,13 +216,13 @@ if (empty($reshook))
 			if ($result < 0)
 			{
 				$langs->load("errors");
-				setEventMessage($langs->trans($company->error), 'errors');
-				setEventMessage($company->errors, 'errors');
+				setEventMessages($langs->trans($company->error), null, 'errors');
+				setEventMessages($company->error, $company->errors, 'errors');
 			}
 		}
 		else
 		{
-			setEventMessage($object->error, 'errors');
+			setEventMessages($object->error, $object->errors, 'errors');
 		}
 	}
 
@@ -236,7 +236,7 @@ if (empty($reshook))
 			$result=$object->send_an_email($langs->transnoentitiesnoconv("ThisIsContentOfYourCard")."\n\n%INFOS%\n\n",$langs->transnoentitiesnoconv("CardContent"));
 
 			$langs->load("mails");
-			setEventMessage($langs->trans("MailSuccessfulySent", $from, $object->email));
+			setEventMessages($langs->trans("MailSuccessfulySent", $from, $object->email), null, 'mesgs');
 		}
 	}
 
@@ -352,7 +352,7 @@ if (empty($reshook))
 							$newfile=$dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']);
 							if (! dol_move_uploaded_file($_FILES['photo']['tmp_name'],$newfile,1,0,$_FILES['photo']['error']) > 0)
 							{
-								setEventMessage($langs->trans("ErrorFailedToSaveFile"), 'errors');
+								setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors');
 							}
 							else
 							{
@@ -368,7 +368,7 @@ if (empty($reshook))
 					}
 					else
 					{
-						setEventMessage("ErrorBadImageFormat", 'errors');
+						setEventMessages("ErrorBadImageFormat", null, 'errors');
 					}
 				}
 				else
@@ -397,9 +397,9 @@ if (empty($reshook))
 			else
 			{
 				if ($object->error) {
-					setEventMessage($object->error, 'errors');
+					setEventMessages($object->error, $object->errors, 'errors');
 				} else {
-					setEventMessage($object->errors, 'errors');
+					setEventMessages($object->error, $object->errors, 'errors');
 				}
 				$action='';
 			}
@@ -503,7 +503,7 @@ if (empty($reshook))
 				if ($num) {
 					$error++;
 					$langs->load("errors");
-					setEventMessage($langs->trans("ErrorLoginAlreadyExists",$login), 'errors');
+					setEventMessages($langs->trans("ErrorLoginAlreadyExists",$login), null, 'errors');
 				}
 			}
 			if (empty($pass)) {
@@ -528,7 +528,7 @@ if (empty($reshook))
 		if ($conf->global->ADHERENT_MAIL_REQUIRED && ! isValidEMail($email)) {
 			$error++;
 			$langs->load("errors");
-			setEventMessage($langs->trans("ErrorBadEMail",$email), 'errors');
+			setEventMessages($langs->trans("ErrorBadEMail",$email), null, 'errors');
 		}
 		$public=0;
 		if (isset($public)) $public=1;
@@ -554,9 +554,9 @@ if (empty($reshook))
 				$db->rollback();
 
 				if ($object->error) {
-					setEventMessage($object->error, 'errors');
+					setEventMessages($object->error, $object->errors, 'errors');
 				} else {
-					setEventMessage($object->errors, 'errors');
+					setEventMessages($object->error, $object->errors, 'errors');
 				}
 
 				$action = 'create';
@@ -609,7 +609,7 @@ if (empty($reshook))
 				if ($result < 0)
 				{
 					$error++;
-					setEventMessage($object->error, 'errors');
+					setEventMessages($object->error, $object->errors, 'errors');
 				}
 			}
 		}
@@ -617,9 +617,9 @@ if (empty($reshook))
 		{
 			$error++;
 			if ($object->error) {
-				setEventMessage($object->error, 'errors');
+				setEventMessages($object->error, $object->errors, 'errors');
 			} else {
-				setEventMessage($object->errors, 'errors');
+				setEventMessages($object->error, $object->errors, 'errors');
 			}
 		}
 
@@ -654,7 +654,7 @@ if (empty($reshook))
 				if ($result < 0)
 				{
 					$error++;
-					setEventMessage($object->error, 'errors');
+					setEventMessages($object->error, $object->errors, 'errors');
 				}
 			}
 			else
@@ -662,9 +662,9 @@ if (empty($reshook))
 				$error++;
 
 				if ($object->error) {
-					setEventMessage($object->error, 'errors');
+					setEventMessages($object->error, $object->errors, 'errors');
 				} else {
-					setEventMessage($object->errors, 'errors');
+					setEventMessages($object->error, $object->errors, 'errors');
 				}
 				$action='';
 			}
@@ -683,7 +683,7 @@ if (empty($reshook))
 		{
 			if (!$mailmanspip->del_to_spip($object))
 			{
-				setEventMessage($langs->trans('DeleteIntoSpipError').': '.$mailmanspip->error, 'errors');
+				setEventMessages($langs->trans('DeleteIntoSpipError').': '.$mailmanspip->error, null, 'errors');
 			}
 		}
 	}
@@ -694,7 +694,7 @@ if (empty($reshook))
 		{
 			if (!$mailmanspip->add_to_spip($object))
 			{
-				setEventMessage($langs->trans('AddIntoSpipError').': '.$mailmanspip->error, 'errors');
+				setEventMessages($langs->trans('AddIntoSpipError').': '.$mailmanspip->error, null, 'errors');
 			}
 		}
 	}
diff --git a/htdocs/adherents/card_subscriptions.php b/htdocs/adherents/card_subscriptions.php
index fa440c3bac4..9d86f618618 100644
--- a/htdocs/adherents/card_subscriptions.php
+++ b/htdocs/adherents/card_subscriptions.php
@@ -110,7 +110,7 @@ if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights
 		{
 			$langs->load("errors");
 			$errmsg=$langs->trans($company->error);
-			setEventMessage($company->errors, 'errors');
+			setEventMessages($company->error, $company->errors, 'errors');
 		}
 		else
 		{
@@ -131,7 +131,7 @@ if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights
         if ($_POST["userid"] != $user->id && $_POST["userid"] != $object->user_id)
         {
             $error++;
-            setEventMessage($langs->trans("ErrorUserPermissionAllowsToLinksToItselfOnly"), 'errors');
+            setEventMessages($langs->trans("ErrorUserPermissionAllowsToLinksToItselfOnly"), null, 'errors');
         }
     }
 
@@ -167,7 +167,7 @@ if ($action == 'setsocid')
                     $thirdparty=new Societe($db);
                     $thirdparty->fetch(GETPOST('socid','int'));
                     $error++;
-	                setEventMessage($langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty",$othermember->getFullName($langs),$othermember->login,$thirdparty->name), 'errors');
+	                setEventMessages($langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty",$othermember->getFullName($langs),$othermember->login,$thirdparty->name), null, 'errors');
                 }
             }
 
diff --git a/htdocs/adherents/ldap.php b/htdocs/adherents/ldap.php
index a2848b655b3..4d9a779d579 100644
--- a/htdocs/adherents/ldap.php
+++ b/htdocs/adherents/ldap.php
@@ -72,12 +72,12 @@ if ($action == 'dolibarr2ldap')
 
 	if ($result >= 0)
 	{
-		setEventMessage($langs->trans("MemberSynchronized"));
+		setEventMessages($langs->trans("MemberSynchronized"), null, 'mesgs');
 		$db->commit();
 	}
 	else
 	{
-		setEventMessage($ldap->error, 'errors');
+		setEventMessages($ldap->errors, $ldap->error, 'errors');
 		$db->rollback();
 	}
 }
diff --git a/htdocs/admin/agenda.php b/htdocs/admin/agenda.php
index 287f2a897eb..c11cbeff3a4 100644
--- a/htdocs/admin/agenda.php
+++ b/htdocs/admin/agenda.php
@@ -86,12 +86,12 @@ if ($action == "save" && empty($cancel))
 
  	if (! $error)
     {
-        setEventMessage($langs->trans("SetupSaved"));
+        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
         $db->commit();
     }
     else
     {
-        setEventMessage($langs->trans("Error"),'errors');
+        setEventMessages($langs->trans("Error"),null, 'errors');
         $db->rollback();
     }
 }
diff --git a/htdocs/admin/agenda_extsites.php b/htdocs/admin/agenda_extsites.php
index 9356674921e..755d1eb23f9 100644
--- a/htdocs/admin/agenda_extsites.php
+++ b/htdocs/admin/agenda_extsites.php
@@ -72,7 +72,7 @@ if ($actionsave)
 
 		if (! empty($src) && ! dol_is_url($src))
 		{
-			setEventMessage($langs->trans("ErrorParamMustBeAnUrl"),'errors');
+			setEventMessages($langs->trans("ErrorParamMustBeAnUrl"), null, 'errors');
 			$error++;
 			$errorsaved++;
 			break;
@@ -104,12 +104,12 @@ if ($actionsave)
     if (! $error)
     {
         $db->commit();
-        setEventMessage($langs->trans("SetupSaved"));
+        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
     }
     else
     {
         $db->rollback();
-        if (empty($errorsaved))	setEventMessage($langs->trans("Error"),'errors');
+        if (empty($errorsaved))	setEventMessages($langs->trans("Error"), null, 'errors');
     }
 }
 
diff --git a/htdocs/admin/agenda_xcal.php b/htdocs/admin/agenda_xcal.php
index dfdac2a8f0f..cd2406e6fdc 100644
--- a/htdocs/admin/agenda_xcal.php
+++ b/htdocs/admin/agenda_xcal.php
@@ -54,12 +54,12 @@ if ($actionsave)
     if ($i >= 4)
     {
         $db->commit();
-        setEventMessage($langs->trans("SetupSaved"));
+        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
     }
     else
     {
         $db->rollback();
-        setEventMessage($langs->trans("SaveFailed"), 'errors');
+        setEventMessages($langs->trans("SaveFailed"), null, 'errors');
     }
 }
 
diff --git a/htdocs/admin/askpricesupplier.php b/htdocs/admin/askpricesupplier.php
index 9bde4673ace..9afcd1a8f62 100644
--- a/htdocs/admin/askpricesupplier.php
+++ b/htdocs/admin/askpricesupplier.php
@@ -6,8 +6,8 @@
  * Copyright (C) 2004      Eric Seigne                 <eric.seigne@ryxeo.com>
  * Copyright (C) 2005-2012 Regis Houssin               <regis.houssin@capnetworks.com>
  * Copyright (C) 2008      Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
- * Copyright (C) 2011-2013 Juanjo Menent                <jmenent@2byte.es>
- * Copyright (C) 2015       Jean-François Ferry		<jfefe@aternatik.fr>
+ * Copyright (C) 2011-2013 Juanjo Menent               <jmenent@2byte.es>
+ * Copyright (C) 2015      Jean-François Ferry		   <jfefe@aternatik.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -54,11 +54,11 @@ if ($action == 'updateMask')
 
  	if (! $error)
 	{
-		setEventMessage($langs->trans("SetupSaved"));
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
 	}
 	else
 	{
-		setEventMessage($langs->trans("Error"),'errors');
+		setEventMessages($langs->trans("Error"), null, 'errors');
 	}
 }
 
@@ -96,13 +96,13 @@ if ($action == 'specimen')
 		}
 		else
 		{
-			setEventMessage($module->error,'errors');
+			setEventMessages($module->error, null, 'errors');
 			dol_syslog($module->error, LOG_ERR);
 		}
 	}
 	else
 	{
-		setEventMessage($langs->trans("ErrorModuleNotFound"),'errors');
+		setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
 		dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
 	}
 }
@@ -116,11 +116,11 @@ if ($action == 'set_ASKPRICESUPPLIER_DRAFT_WATERMARK')
 
  	if (! $error)
 	{
-		setEventMessage($langs->trans("SetupSaved"));
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
 	}
 	else
 	{
-		setEventMessage($langs->trans("Error"),'errors');
+		setEventMessages($langs->trans("Error"), null, 'errors');
 	}
 }
 
@@ -134,11 +134,11 @@ if ($action == 'set_ASKPRICESUPPLIER_FREE_TEXT')
 
  	if (! $error)
 	{
-		setEventMessage($langs->trans("SetupSaved"));
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
 	}
 	else
 	{
-		setEventMessage($langs->trans("Error"),'errors');
+		setEventMessages($langs->trans("Error"), null, 'errors');
 	}
 }
 
@@ -150,11 +150,11 @@ if ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_ASKPRICESUPPLIER')
 
     if (! $error)
     {
-        setEventMessage($langs->trans("SetupSaved"));
+        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
     }
     else
     {
-        setEventMessage($langs->trans("Error"),'errors');
+        setEventMessages($langs->trans("Error"), null, 'errors');
     }
 }
 
@@ -178,12 +178,12 @@ if ($action == 'setModuleOptions')
 	if (! $error)
 	{
 		$db->commit();
-		setEventMessage($langs->trans("SetupSaved"));
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
 	}
 	else
 	{
 		$db->rollback();
-		setEventMessage($langs->trans("Error"),'errors');
+		setEventMessages($langs->trans("Error"), null, 'errors');
 	}
 }
 
diff --git a/htdocs/admin/bank.php b/htdocs/admin/bank.php
index 8214755fd2b..048e351044d 100644
--- a/htdocs/admin/bank.php
+++ b/htdocs/admin/bank.php
@@ -56,11 +56,11 @@ if ($action == 'set_BANK_CHEQUERECEIPT_FREE_TEXT')
 
  	if (! $error)
     {
-        setEventMessage($langs->trans("SetupSaved"));
+        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
     }
     else
     {
-        setEventMessage($langs->trans("Error"),'errors');
+        setEventMessages($langs->trans("Error"), null, 'errors');
     }
 }
 
diff --git a/htdocs/admin/barcode.php b/htdocs/admin/barcode.php
index b36a222c165..0a57508c271 100644
--- a/htdocs/admin/barcode.php
+++ b/htdocs/admin/barcode.php
@@ -97,11 +97,11 @@ if ($action == 'setModuleOptions')
 
  	if (! $error)
     {
-        setEventMessage($langs->trans("SetupSaved"));
+        setEventMessages($langs->trans("SetupSaved"), null, 'msgs');
     }
     else
     {
-        setEventMessage($langs->trans("Error"),'errors');
+        setEventMessages($langs->trans("Error"), null, 'errors');
     }
 }
 
@@ -111,11 +111,11 @@ if ($action && $action != 'setcoder' && $action != 'setModuleOptions')
 
  	if (! $error)
     {
-        setEventMessage($langs->trans("SetupSaved"));
+        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
     }
     else
     {
-        setEventMessage($langs->trans("Error"),'errors');
+        setEventMessages($langs->trans("Error"), null, 'errors');
     }
 }
 
diff --git a/htdocs/admin/boxes.php b/htdocs/admin/boxes.php
index 6b1eb71fafe..5b6d64801b5 100644
--- a/htdocs/admin/boxes.php
+++ b/htdocs/admin/boxes.php
@@ -85,7 +85,7 @@ if ($action == 'add') {
                     }
                     else
                     {
-                        setEventMessage($db->lasterror(), 'errors');
+                        setEventMessages($db->lasterror(), null, 'errors');
                         $error++;
                     }
                 }
@@ -121,7 +121,7 @@ if ($action == 'add') {
                         $resql = $db->query($sql);
                         if (! $resql)
                         {
-                            setEventMessage($db->lasterror(), 'errors');
+                            setEventMessages($db->lasterror(), null, 'errors');
                             $error++;
                         }
                     }
diff --git a/htdocs/admin/clicktodial.php b/htdocs/admin/clicktodial.php
index 1550c0ebef7..260a9514375 100644
--- a/htdocs/admin/clicktodial.php
+++ b/htdocs/admin/clicktodial.php
@@ -41,11 +41,11 @@ if ($action == 'setvalue' && $user->admin)
     $result=dolibarr_set_const($db, "CLICKTODIAL_URL", GETPOST("url"), 'chaine', 0, '', $conf->entity);
     if ($result >= 0)
     {
-		setEventMessage($langs->trans("SetupSaved"));
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
     }
     else
     {
-        setEventMessage($langs->trans("Error"),'errors');
+        setEventMessages($langs->trans("Error"), null, 'errors');
     }
 }
 
diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php
index f7e3812d74f..9e55369dac9 100644
--- a/htdocs/admin/commande.php
+++ b/htdocs/admin/commande.php
@@ -7,7 +7,7 @@
  * Copyright (C) 2005-2014 Regis Houssin                <regis.houssin@capnetworks.com>
  * Copyright (C) 2008 	   Raphael Bertrand (Resultic)  <raphael.bertrand@resultic.fr>
  * Copyright (C) 2011-2013 Juanjo Menent			    <jmenent@2byte.es>
- * Copyright (C) 2011-2013 Philippe Grand			    <philippe.grand@atoo-net.com>
+ * Copyright (C) 2011-2015 Philippe Grand			    <philippe.grand@atoo-net.com>
  * Copyright (C) 2013 	   Florian Henry			    <florian.henry@open-concept.pro>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -64,11 +64,11 @@ if ($action == 'updateMask')
 
  	if (! $error)
     {
-        setEventMessage($langs->trans("SetupSaved"));
+        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
     }
     else
     {
-        setEventMessage($langs->trans("Error"),'errors');
+        setEventMessages($langs->trans("Error"), null, 'errors');
     }
 }
 
@@ -106,13 +106,13 @@ else if ($action == 'specimen')
 		}
 		else
 		{
-			setEventMessage($module->error,'errors');
+			setEventMessages($module->error, null, 'errors');
 			dol_syslog($module->error, LOG_ERR);
 		}
 	}
 	else
 	{
-		setEventMessage($langs->trans("ErrorModuleNotFound"),'errors');
+		setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
 		dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
 	}
 }
@@ -137,12 +137,12 @@ if ($action == 'setModuleOptions')
 	if (! $error)
 	{
 		$db->commit();
-		setEventMessage($langs->trans("SetupSaved"));
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
 	}
 	else
 	{
 		$db->rollback();
-		setEventMessage($langs->trans("Error"),'errors');
+		setEventMessages($langs->trans("Error"), null, 'errors');
 	}
 }
 
@@ -196,11 +196,11 @@ else if ($action == 'set_COMMANDE_DRAFT_WATERMARK')
 
  	if (! $error)
     {
-        setEventMessage($langs->trans("SetupSaved"));
+        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
     }
     else
     {
-        setEventMessage($langs->trans("Error"),'errors');
+        setEventMessages($langs->trans("Error"), null, 'errors');
     }
 }
 
@@ -214,11 +214,11 @@ else if ($action == 'set_ORDER_FREE_TEXT')
 
  	if (! $error)
     {
-        setEventMessage($langs->trans("SetupSaved"));
+        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
     }
     else
     {
-        setEventMessage($langs->trans("Error"),'errors');
+        setEventMessages($langs->trans("Error"), null, 'errors');
     }
 }
 
@@ -228,9 +228,9 @@ else if ($action=="setshippableiconinlist") {
     $res = dolibarr_set_const($db, "SHIPPABLE_ORDER_ICON_IN_LIST", $setshippableiconinlist,'yesno',0,'',$conf->entity);
     if (! $res > 0) $error++;
     if (! $error) {
-        setEventMessage($langs->trans("SetupSaved"));
+        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
     } else {
-        setEventMessage($langs->trans("Error"), 'errors');
+        setEventMessages($langs->trans("Error"), null, 'errors');
     }
 }
 
@@ -243,11 +243,11 @@ else if ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_ORDER')
 
     if (! $error)
     {
-        setEventMessage($langs->trans("SetupSaved"));
+        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
     }
     else
     {
-        setEventMessage($langs->trans("Error"),'errors');
+        setEventMessages($langs->trans("Error"), null, 'errors');
     }
 }
 
@@ -260,11 +260,11 @@ else if ($action == 'set_WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER')
 
     if (! $error)
     {
-        setEventMessage($langs->trans("SetupSaved"));
+        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
     }
     else
     {
-        setEventMessage($langs->trans("Error"),'errors');
+        setEventMessages($langs->trans("Error"), null, 'errors');
     }
 }
 
diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php
index b9660c8a04d..e84bdf2a3fa 100644
--- a/htdocs/admin/company.php
+++ b/htdocs/admin/company.php
@@ -3,7 +3,7 @@
  * Copyright (C) 2004-2013	Laurent Destailleur		<eldy@users.sourceforge.net>
  * Copyright (C) 2005-2012	Regis Houssin			<regis.houssin@capnetworks.com>
  * Copyright (C) 2010-2014	Juanjo Menent			<jmenent@2byte.es>
- * Copyright (C) 2011		Philippe Grand			<philippe.grand@atoo-net.com>
+ * Copyright (C) 2011-2015	Philippe Grand			<philippe.grand@atoo-net.com>
  * Copyright (C) 2015       Alexandre Spangaro      <aspangaro.dolibarr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -125,19 +125,19 @@ if ( ($action == 'update' && empty($_POST["cancel"]))
 					$error++;
 					$langs->load("errors");
 					$tmparray=explode(':',$result);
-					setEventMessage($langs->trans('ErrorFileIsInfectedWithAVirus',$tmparray[1]),'errors');
+					setEventMessages($langs->trans('ErrorFileIsInfectedWithAVirus',$tmparray[1]), null, 'errors');
 				}
 				else
 				{
 					$error++;
-					setEventMessage($langs->trans("ErrorFailedToSaveFile"),'errors');
+					setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors');
 				}
 			}
 			else
 			{
 				$error++;
 				$langs->load("errors");
-				setEventMessage($langs->trans("ErrorBadImageFormat"),'errors');
+				setEventMessages($langs->trans("ErrorBadImageFormat"), null, 'errors');
 			}
 		}
 	}
@@ -230,7 +230,7 @@ if ($action == 'addthumb')
 		{
 			$error++;
 			$langs->load("errors");
-			setEventMessage($langs->trans("ErrorBadImageFormat"),'errors');
+			setEventMessages($langs->trans("ErrorBadImageFormat"), null, 'errors');
 			dol_syslog($langs->transnoentities("ErrorBadImageFormat"),LOG_WARNING);
 		}
 	}
@@ -238,7 +238,7 @@ if ($action == 'addthumb')
 	{
 		$error++;
 		$langs->load("errors");
-		setEventMessage($langs->trans("ErrorFileDoesNotExists",$_GET["file"]),'errors');
+		setEventMessages($langs->trans("ErrorFileDoesNotExists",$_GET["file"]), null, 'errors');
 		dol_syslog($langs->transnoentities("ErrorFileDoesNotExists",$_GET["file"]),LOG_WARNING);
 	}
 }
diff --git a/htdocs/admin/compta.php b/htdocs/admin/compta.php
index 633f88b9cfb..38ba28e9fa4 100644
--- a/htdocs/admin/compta.php
+++ b/htdocs/admin/compta.php
@@ -3,7 +3,7 @@
  * Copyright (C) 2004-2008 Laurent Destailleur  <eldy@users.sourceforge.net>
  * Copyright (C) 2005-2009 Regis Houssin        <regis.houssin@capnetworks.com>
  * Copyright (C) 2011-2013 Juanjo Menent	    <jmenent@2byte.es>
- * Copyright (C) 2013      Philippe Grand	    <philippe.grand@atoo-net.com>
+ * Copyright (C) 2013-2015 Philippe Grand	    <philippe.grand@atoo-net.com>
  * Copyright (C) 2014      Marcos García        <marcosgdf@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -87,11 +87,11 @@ if ($action == 'update')
 
     if (! $error)
     {
-        setEventMessage($langs->trans("SetupSaved"));
+        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
     }
     else
     {
-        setEventMessage($langs->trans("Error"),'errors');
+        setEventMessages($langs->trans("Error"), null, 'errors');
     }
 }
 
diff --git a/htdocs/admin/const.php b/htdocs/admin/const.php
index 62f6bbaaf2c..06e3279fa54 100644
--- a/htdocs/admin/const.php
+++ b/htdocs/admin/const.php
@@ -68,7 +68,7 @@ if ($action == 'add' || (GETPOST('add') && $action != 'update'))
 	{
 		if (dolibarr_set_const($db, $constname, $constvalue, 'chaine', 1, $constnote, $entity) >= 0)
 		{
-			setEventMessage($langs->trans("RecordSaved"));
+			setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
 			$action="";
 			$constname="";
 			$constvalue="";
@@ -99,7 +99,7 @@ if (! empty($consts) && $action == 'update')
 			}
 		}
 	}
-	if ($nbmodified > 0) setEventMessage($langs->trans("RecordSaved"));
+	if ($nbmodified > 0) setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
 	$action='';
 }
 
@@ -122,7 +122,7 @@ if (! empty($consts) && $action == 'delete')
 			}
 		}
 	}
-	if ($nbdeleted > 0) setEventMessage($langs->trans("RecordDeleted"));
+	if ($nbdeleted > 0) setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
 	$action='';
 }
 
@@ -131,7 +131,7 @@ if ($action == 'delete')
 {
 	if (dolibarr_del_const($db, $rowid, $entity) >= 0)
 	{
-		setEventMessage($langs->trans("RecordDeleted"));
+		setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
 	}
 	else
 	{
diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php
index a45045a5381..3198ad51448 100644
--- a/htdocs/admin/contract.php
+++ b/htdocs/admin/contract.php
@@ -1,6 +1,6 @@
 <?php
 /* Copyright (C) 2011-2013      Juanjo Menent	    <jmenent@2byte.es>
- * Copyright (C) 2011-2014      Philippe Grand	    <philippe.grand@atoo-net.com>
+ * Copyright (C) 2011-2015      Philippe Grand	    <philippe.grand@atoo-net.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -59,11 +59,11 @@ if ($action == 'updateMask')
 
  	if (! $error)
     {
-        setEventMessage($langs->trans("SetupSaved"));
+        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
     }
     else
     {
-        setEventMessage($langs->trans("Error"),'errors');
+        setEventMessage($langs->trans("Error"), null, 'errors');
     }
 }
 
@@ -101,13 +101,13 @@ else if ($action == 'specimen') // For contract
 		}
 		else
 		{
-			setEventMessage($obj->error,'errors');
+			setEventMessages($obj->error, $obj->errors, 'errors');
 			dol_syslog($obj->error, LOG_ERR);
 		}
 	}
 	else
 	{
-		setEventMessage($langs->trans("ErrorModuleNotFound"),'errors');
+		setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
 		dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
 	}
 }
@@ -132,12 +132,12 @@ if ($action == 'setModuleOptions')
 	if (! $error)
 	{
 		$db->commit();
-		setEventMessage($langs->trans("SetupSaved"));
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
 	}
 	else
 	{
 		$db->rollback();
-        setEventMessage($langs->trans("Error"),'errors');
+        setEventMessages($langs->trans("Error"), null, 'errors');
 	}
 }
 
@@ -194,11 +194,11 @@ else if ($action == 'set_other')
 
  	if (! $error)
     {
-        setEventMessage($langs->trans("SetupSaved"));
+        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
     }
     else
     {
-        setEventMessage($langs->trans("Error"),'errors');
+        setEventMessages($langs->trans("Error"), null, 'errors');
     }
 }
 
diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php
index 40b4676ba25..817019cc24b 100644
--- a/htdocs/admin/dict.php
+++ b/htdocs/admin/dict.php
@@ -4,7 +4,7 @@
  * Copyright (C) 2004      Benoit Mortier       <benoit.mortier@opensides.be>
  * Copyright (C) 2005-2012 Regis Houssin        <regis.houssin@capnetworks.com>
  * Copyright (C) 2010-2013 Juanjo Menent        <jmenent@2byte.es>
- * Copyright (C) 2011      Philippe Grand       <philippe.grand@atoo-net.com>
+ * Copyright (C) 2011-2015 Philippe Grand       <philippe.grand@atoo-net.com>
  * Copyright (C) 2011      Remy Younes          <ryounes@gmail.com>
  * Copyright (C) 2012-2015 Marcos García        <marcosgdf@gmail.com>
  * Copyright (C) 2012      Christophe Battarel	<christophe.battarel@ltairis.fr>
@@ -548,20 +548,20 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
             if ($fieldnamekey == 'deductible') $fieldnamekey = 'Deductible';
             if ($fieldnamekey == 'sortorder') $fieldnamekey = 'SortOrder';
 
-            setEventMessage($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)),'errors');
+            setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors');
         }
     }
     // Other checks
     if ($tabname[$id] == MAIN_DB_PREFIX."c_actioncomm" && isset($_POST["type"]) && in_array($_POST["type"],array('system','systemauto'))) {
         $ok=0;
-        setEventMessage($langs->transnoentities('ErrorReservedTypeSystemSystemAuto'),'errors');
+        setEventMessages($langs->transnoentities('ErrorReservedTypeSystemSystemAuto'), null, 'errors');
     }
     if (isset($_POST["code"]))
     {
     	if ($_POST["code"]=='0')
     	{
         	$ok=0;
-    		setEventMessage($langs->transnoentities('ErrorCodeCantContainZero'),'errors');
+    		setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors');
         }
         /*if (!is_numeric($_POST['code']))	// disabled, code may not be in numeric base
     	{
@@ -578,7 +578,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
     	else
     	{
         	$ok=0;
-        	setEventMessage($langs->transnoentities("ErrorFieldRequired",$langs->transnoentities("Country")),'errors');
+        	setEventMessages($langs->transnoentities("ErrorFieldRequired",$langs->transnoentities("Country")), null, 'errors');
     	}
     }
 
@@ -637,13 +637,13 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
         $result = $db->query($sql);
         if ($result)	// Add is ok
         {
-            setEventMessage($langs->transnoentities("RecordSaved"));
+            setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
         	$_POST=array('id'=>$id);	// Clean $_POST array, we keep only
         }
         else
         {
             if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
-                setEventMessage($langs->transnoentities("ErrorRecordAlreadyExists"),'errors');
+                setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors');
             }
             else {
                 dol_print_error($db);
@@ -687,7 +687,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
         $resql = $db->query($sql);
         if (! $resql)
         {
-            setEventMessage($db->error(),'errors');
+            setEventMessage($db->error(), 'errors');
         }
     }
     //$_GET["id"]=GETPOST('id', 'int');       // Force affichage dictionnaire en cours d'edition
@@ -711,7 +711,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes')       // delete
     {
         if ($db->errno() == 'DB_ERROR_CHILD_EXISTS')
         {
-            setEventMessage($langs->transnoentities("ErrorRecordIsUsedByChild"),'errors');
+            setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors');
         }
         else
         {
diff --git a/htdocs/admin/menus/edit.php b/htdocs/admin/menus/edit.php
index 7c60a2ee055..b7f4b8d5b73 100644
--- a/htdocs/admin/menus/edit.php
+++ b/htdocs/admin/menus/edit.php
@@ -78,16 +78,16 @@ if ($action == 'update')
             $result=$menu->update($user);
             if ($result > 0)
             {
-	            setEventMessage($langs->trans("RecordModifiedSuccessfully"));
+	            setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
             }
             else
             {
-	            setEventMessage($menu->error, 'errors');
+	            setEventMessages($menu->error, $menu->errors, 'errors');
             }
         }
         else
         {
-	        setEventMessage($menu->error, 'errors');
+	        setEventMessages($menu->error, $menu->errors, 'errors');
         }
         $_GET["menuId"] = $_POST['menuId'];
         $action = "edit";
@@ -159,13 +159,13 @@ if ($action == 'add')
     }
     if (! $error && $_POST['menuId'] && $_POST['type'] == 'top')
     {
-	    setEventMessage($langs->trans("ErrorTopMenuMustHaveAParentWithId0"), 'errors');
+	    setEventMessages($langs->trans("ErrorTopMenuMustHaveAParentWithId0"), null, 'errors');
         $action = 'create';
         $error++;
     }
     if (! $error && empty($_POST['menuId']) && $_POST['type'] == 'left')
     {
-	    setEventMessage($langs->trans("ErrorLeftMenuMustHaveAParentId"), 'errors');
+	    setEventMessages($langs->trans("ErrorLeftMenuMustHaveAParentId"), null, 'errors');
         $action = 'create';
         $error++;
     }
@@ -204,7 +204,7 @@ if ($action == 'add')
         else
         {
             $action = 'create';
-	        setEventMessage($menu->error, 'errors');
+	        setEventMessages($menu->error, $menu->errors, 'errors');
         }
     }
 }
@@ -222,7 +222,7 @@ if ($action == 'confirm_delete' && $_POST["confirm"] == 'yes')
         $this->db->commit();
 
         llxHeader();
-	    setEventMessage($langs->trans("MenuDeleted"));
+	    setEventMessages($langs->trans("MenuDeleted"), null, 'mesgs');
         llxFooter();
         exit ;
     }
diff --git a/htdocs/admin/menus/index.php b/htdocs/admin/menus/index.php
index c8699209268..7da0673b196 100644
--- a/htdocs/admin/menus/index.php
+++ b/htdocs/admin/menus/index.php
@@ -186,7 +186,7 @@ elseif ($action == 'confirm_delete' && $confirm == 'yes')
 	{
 		$db->commit();
 
-		setEventMessage($langs->trans("MenuDeleted"));
+		setEventMessages($langs->trans("MenuDeleted"), null, 'mesgs');
 
 		header("Location: ".DOL_URL_ROOT.'/admin/menus/index.php?menu_handler='.$menu_handler);
 		exit ;
@@ -359,7 +359,7 @@ if ($conf->use_javascript_ajax)
 else
 {
 	$langs->load("errors");
-	setEventMessage($langs->trans("ErrorFeatureNeedJavascript"), 'errors');
+	setEventMessages($langs->trans("ErrorFeatureNeedJavascript"), null, 'errors');
 }
 
 print '<br>';
diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php
index a460f667e2a..49d229898b8 100644
--- a/htdocs/admin/tools/dolibarr_export.php
+++ b/htdocs/admin/tools/dolibarr_export.php
@@ -52,8 +52,8 @@ if ($action == 'delete')
 {
 	$file=$conf->admin->dir_output.'/'.GETPOST('urlfile');
     $ret=dol_delete_file($file, 1);
-    if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
-    else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
+    if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs');
+    else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors');
     $action='';
 }
 
diff --git a/htdocs/admin/tools/export.php b/htdocs/admin/tools/export.php
index 500c766ed77..cddd42a8623 100644
--- a/htdocs/admin/tools/export.php
+++ b/htdocs/admin/tools/export.php
@@ -60,8 +60,8 @@ if ($action == 'delete')
 {
 	$file=$conf->admin->dir_output.'/'.GETPOST('urlfile');
 	$ret=dol_delete_file($file, 1);
-	if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
-	else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
+	if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs');
+	else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors');
 	$action='';
 }
 
@@ -357,7 +357,7 @@ if ($what == 'postgresql')
 //{
     if ($errormsg)
     {
-    	setEventMessage($langs->trans("Error")." : ".$errormsg, 'errors');
+    	setEventMessages($langs->trans("Error")." : ".$errormsg, null, 'errors');
 
     	$resultstring='';
         $resultstring.='<div class="error">'.$langs->trans("Error")." : ".$errormsg.'</div>';
@@ -368,7 +368,7 @@ if ($what == 'postgresql')
 	{
 		if ($what)
 		{
-	        setEventMessage($langs->trans("BackupFileSuccessfullyCreated").'.<br>'.$langs->trans("YouCanDownloadBackupFile"));
+	        setEventMessages($langs->trans("BackupFileSuccessfullyCreated").'.<br>'.$langs->trans("YouCanDownloadBackupFile"), null, 'mesgs');
 
 	        $resultstring='<div class="ok">';
 	        $resultstring.=$langs->trans("BackupFileSuccessfullyCreated").'.<br>';
@@ -379,7 +379,7 @@ if ($what == 'postgresql')
 		}
 		else
 		{
-			setEventMessage($langs->trans("YouMustRunCommandFromCommandLineAfterLoginToUser",$dolibarr_main_db_user,$dolibarr_main_db_user));
+			setEventMessages($langs->trans("YouMustRunCommandFromCommandLineAfterLoginToUser",$dolibarr_main_db_user,$dolibarr_main_db_user), null, 'mesgs');
 		}
     }
 //}
diff --git a/htdocs/admin/tools/update.php b/htdocs/admin/tools/update.php
index 54a6cab9cbd..e1166e96c3d 100644
--- a/htdocs/admin/tools/update.php
+++ b/htdocs/admin/tools/update.php
@@ -34,7 +34,7 @@ $action=GETPOST('action','alpha');
 if (! $user->admin) accessforbidden();
 
 if (GETPOST('msg','alpha')) {
-	setEventMessage(GETPOST('msg','alpha'), 'errors');
+	setEventMessages(GETPOST('msg','alpha'), null, 'errors');
 }
 
 
@@ -63,7 +63,7 @@ if ($action=='install')
 	if (! $original_file)
 	{
 		$langs->load("Error");
-		setEventMessage($langs->trans("ErrorFileRequired"), 'warnings');
+		setEventMessages($langs->trans("ErrorFileRequired"), null, 'warnings');
 		$error++;
 	}
 	else
@@ -71,7 +71,7 @@ if ($action=='install')
 		if (! preg_match('/\.zip/i',$original_file))
 		{
 			$langs->load("errors");
-			setEventMessage($langs->trans("ErrorFileMustBeADolibarrPackage",$original_file), 'errors');
+			setEventMessages($langs->trans("ErrorFileMustBeADolibarrPackage",$original_file), null, 'errors');
 			$error++;
 		}
 	}
@@ -99,7 +99,7 @@ if ($action=='install')
 			if (! empty($result['error']))
 			{
 				$langs->load("errors");
-				setEventMessage($langs->trans($result['error'],$original_file), 'errors');
+				setEventMessages($langs->trans($result['error'],$original_file), null, 'errors');
 				$error++;
 			}
 			else
@@ -116,7 +116,7 @@ if ($action=='install')
 					//var_dump($modulenamedir);
 					if (! dol_is_dir($modulenamedir))
 					{
-						setEventMessage($langs->trans("ErrorModuleFileSeemsToHaveAWrongFormat"), 'errors');
+						setEventMessages($langs->trans("ErrorModuleFileSeemsToHaveAWrongFormat"), null, 'errors');
 						$error++;
 					}
 				}
@@ -128,7 +128,7 @@ if ($action=='install')
 					$result=dolCopyDir($modulenamedir, $dirins.'/'.$modulename, '0444', 1);
 					if ($result <= 0)
 					{
-						setEventMessage($langs->trans("ErrorFailedToCopy"), 'errors');
+						setEventMessages($langs->trans("ErrorFailedToCopy"), null, 'errors');
 						$error++;
 					}
 				}
@@ -142,7 +142,7 @@ if ($action=='install')
 
 	if (! $error)
 	{
-		setEventMessage($langs->trans("SetupIsReadyForUse"));
+		setEventMessages($langs->trans("SetupIsReadyForUse"), null, 'mesgs');
 	}
 }
 
-- 
GitLab