From 31d99bbfe6c0956c4b9633e2f4127808602366ff Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@destailleur.fr>
Date: Tue, 2 May 2017 11:28:40 +0200
Subject: [PATCH] Complete event tracked automatically

---
 ...terface_50_modAgenda_ActionsAuto.class.php |  73 +--
 htdocs/expensereport/card.php                 | 478 ++++++++++--------
 .../mysql/data/llx_c_action_trigger.sql       |   4 +
 .../install/mysql/migration/5.0.0-6.0.0.sql   |  22 +
 htdocs/install/mysql/tables/llx_holiday.sql   |   4 +-
 5 files changed, 304 insertions(+), 277 deletions(-)

diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php
index 84517e36c08..bce6d69b2fa 100644
--- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php
+++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php
@@ -87,7 +87,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("NewCompanyToDolibarr",$object->name);
             $object->actionmsg=$langs->transnoentities("NewCompanyToDolibarr",$object->name);
             if (! empty($object->prefix)) $object->actionmsg.=" (".$object->prefix.")";
-            $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
 
 			$object->sendtoid=0;
 			$object->socid=$object->id;
@@ -100,7 +99,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
 
             if (empty($object->actiontypecode)) $object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) dol_syslog('Trigger called with property actionmsg2 on object not defined', LOG_ERR);
-            $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
 
             // Parameters $object->sendtoid defined by caller
             //$object->sendtoid=0;
@@ -114,7 +112,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
 			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ContractValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
             $object->actionmsg=$langs->transnoentities("ContractValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
-            $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
 
             $object->sendtoid=0;
 		}
@@ -127,7 +124,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
 			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
             $object->actionmsg=$langs->transnoentities("PropalValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
-            $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
 
 			$object->sendtoid=0;
 		}
@@ -142,7 +138,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             if (empty($object->actionmsg))
             {
                 $object->actionmsg=$langs->transnoentities("ProposalSentByEMail",$object->ref);
-                $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
             }
 
             // Parameters $object->sendtoid defined by caller
@@ -157,7 +152,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
 			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref);
             $object->actionmsg=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref);
-            $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
 
 			$object->sendtoid=0;
 		}
@@ -170,7 +164,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
 			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClassifiedBilledInDolibarr",$object->ref);
             $object->actionmsg=$langs->transnoentities("PropalClassifiedBilledInDolibarr",$object->ref);
-            $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
 
 			$object->sendtoid=0;
 		}
@@ -183,7 +176,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
 			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref);
             $object->actionmsg=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref);
-            $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
 
 			$object->sendtoid=0;
 		}
@@ -195,7 +187,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
 			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
             $object->actionmsg=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
-            $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
 
 			$object->sendtoid=0;
 		}
@@ -208,7 +199,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
 			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderDeliveredInDolibarr",$object->ref);
             $object->actionmsg=$langs->transnoentities("OrderDeliveredInDolibarr",$object->ref);
-            $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
 
 			$object->sendtoid=0;
 		}
@@ -221,7 +211,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
 			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderBilledInDolibarr",$object->ref);
             $object->actionmsg=$langs->transnoentities("OrderBilledInDolibarr",$object->ref);
-            $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
 
 			$object->sendtoid=0;
 		}
@@ -234,7 +223,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
 			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderCanceledInDolibarr",$object->ref);
             $object->actionmsg=$langs->transnoentities("OrderCanceledInDolibarr",$object->ref);
-            $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
 
 			$object->sendtoid=0;
 		}
@@ -249,7 +237,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             if (empty($object->actionmsg))
             {
                 $object->actionmsg=$langs->transnoentities("OrderSentByEMail",$object->ref);
-                $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
             }
 
             // Parameters $object->sendtoid defined by caller
@@ -264,7 +251,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
 			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
             $object->actionmsg=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
-            $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
 
 			$object->sendtoid=0;
 		}
@@ -277,7 +263,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
 			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref);
             $object->actionmsg=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref);
-            $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
 
 			$object->sendtoid=0;
 		}
@@ -292,7 +277,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             if (empty($object->actionmsg))
             {
                 $object->actionmsg=$langs->transnoentities("InvoiceSentByEMail",$object->ref);
-                $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
             }
 
             // Parameters $object->sendtoid defined by caller
@@ -308,7 +292,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
 			$object->actiontypecode='AC_OTH_AUTO';
             $object->actionmsg2=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref);
             $object->actionmsg=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref);
-            $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
 
             $object->sendtoid=0;
 		}
@@ -321,7 +304,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
 			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref);
             $object->actionmsg=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref);
-            $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
 
             $object->sendtoid=0;
 		}
@@ -334,7 +316,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
 			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionCreatedInDolibarr",$object->ref);
             $object->actionmsg=$langs->transnoentities("InterventionCreatedInDolibarr",$object->ref);
-            $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
 
             $object->sendtoid=0;
 			$object->fk_element=0;
@@ -349,7 +330,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
 			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
             $object->actionmsg=$langs->transnoentities("InterventionValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
-            $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
 
             $object->sendtoid=0;
 			$object->fk_element=0;
@@ -364,7 +344,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
 			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionModifiedInDolibarr",$object->ref);
             $object->actionmsg=$langs->transnoentities("InterventionModifiedInDolibarr",$object->ref);
-            $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
 
             $object->sendtoid=0;
 			$object->fk_element=0;
@@ -379,7 +358,7 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionSentByEMail",$object->ref);
             $object->actionmsg=$langs->transnoentities("InterventionSentByEMail",$object->ref);
-            $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
+
             // Parameters $object->sendtoid defined by caller
             //$object->sendtoid=0;
         }
@@ -392,7 +371,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $object->actiontypecode='AC_OTH_AUTO';
            	if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionClassifiedBilledInDolibarr",$object->ref);
            	$object->actionmsg=$langs->transnoentities("InterventionClassifiedBilledInDolibarr",$object->ref);
-            $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
 
             $object->sendtoid=0;
         }
@@ -405,7 +383,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $object->actiontypecode='AC_OTH_AUTO';
            	if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionClassifiedUnbilledInDolibarr",$object->ref);
            	$object->actionmsg=$langs->transnoentities("InterventionClassifiedUnbilledInDolibarr",$object->ref);
-            $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
 
             $object->sendtoid=0;
         }
@@ -418,7 +395,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
 			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionDeletedInDolibarr",$object->ref);
             $object->actionmsg=$langs->transnoentities("InterventionDeletedInDolibarr",$object->ref);
-            $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
 
             $object->sendtoid=0;
 			$object->fk_element=0;
@@ -435,7 +411,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
         	if (empty($object->actionmsg))
         	{
         		$object->actionmsg=$langs->transnoentities("ShippingValidated",($object->newref?$object->newref:$object->ref));
-        		$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
         	}
 
         	// Parameters $object->sendtoid defined by caller
@@ -452,7 +427,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             if (empty($object->actionmsg))
             {
                 $object->actionmsg=$langs->transnoentities("ShippingSentByEMail",$object->ref);
-                $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
             }
 
             // Parameters $object->sendtoid defined by caller
@@ -467,7 +441,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
 			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderCreatedInDolibarr",($object->newref?$object->newref:$object->ref));
             $object->actionmsg=$langs->transnoentities("OrderCreatedInDolibarr",($object->newref?$object->newref:$object->ref));
-            $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
 
             $object->sendtoid=0;
 		}
@@ -480,7 +453,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
 			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
             $object->actionmsg=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
-            $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
 
             $object->sendtoid=0;
 		}
@@ -493,7 +465,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
 			$object->actiontypecode='AC_OTH_AUTO';
 			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderApprovedInDolibarr",$object->ref);
 			$object->actionmsg=$langs->transnoentities("OrderApprovedInDolibarr",$object->ref);
-			$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
 
 			$object->sendtoid=0;
 		}
@@ -506,7 +477,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
 			$object->actiontypecode='AC_OTH_AUTO';
 			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderRefusedInDolibarr",$object->ref);
 			$object->actionmsg=$langs->transnoentities("OrderRefusedInDolibarr",$object->ref);
-			$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
 
 			$object->sendtoid=0;
 		}
@@ -519,7 +489,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
 			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierOrderSubmitedInDolibarr",($object->newref?$object->newref:$object->ref));
             $object->actionmsg=$langs->transnoentities("SupplierOrderSubmitedInDolibarr",($object->newref?$object->newref:$object->ref));
-            $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
 
             $object->sendtoid=0;
 		}
@@ -532,7 +501,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
 			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierOrderReceivedInDolibarr",($object->newref?$object->newref:$object->ref));
             $object->actionmsg=$langs->transnoentities("SupplierOrderReceivedInDolibarr",($object->newref?$object->newref:$object->ref));
-            $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
 
             $object->sendtoid=0;
 		}
@@ -548,7 +516,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             if (empty($object->actionmsg))
             {
                 $object->actionmsg=$langs->transnoentities("SupplierOrderSentByEMail",$object->ref);
-                $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
             }
 
             // Parameters $object->sendtoid defined by caller
@@ -566,7 +533,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             if (empty($object->actionmsg))
             {
                 $object->actionmsg=$langs->transnoentities("SupplierOrderClassifiedBilled",$object->ref);
-                $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
             }
 
             $object->sendtoid=0;
@@ -580,7 +546,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
 			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
             $object->actionmsg=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
-            $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
 
             $object->sendtoid=0;
 		}
@@ -593,7 +558,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
 			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref);
             $object->actionmsg=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref);
-            $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
 
             $object->sendtoid=0;
 		}
@@ -609,7 +573,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             if (empty($object->actionmsg))
             {
                 $object->actionmsg=$langs->transnoentities("SupplierInvoiceSentByEMail",$object->ref);
-                $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
             }
 
             // Parameters $object->sendtoid defined by caller
@@ -624,7 +587,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
 			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref);
             $object->actionmsg=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref);
-            $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
 
 			$object->sendtoid=0;
 		}
@@ -637,7 +599,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
 			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref);
             $object->actionmsg=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref);
-            $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
 
 			$object->sendtoid=0;
 		}
@@ -654,7 +615,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $object->actionmsg=$langs->transnoentities("MemberValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
             $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
             $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
-            $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
 
 			$object->sendtoid=0;
         }
@@ -669,7 +629,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $object->actionmsg=$langs->transnoentities("MemberModifiedInDolibarr",$object->ref);
             $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
             $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
-            $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
 
             $object->sendtoid=0;
 		}
@@ -686,7 +645,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
             $object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount;
             $object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start,'day').' - '.dol_print_date($object->last_subscription_date_end,'day');
-            $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
 
 			$object->sendtoid=0;
         }
@@ -701,7 +659,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $object->actionmsg=$langs->transnoentities("MemberResiliatedInDolibarr",$object->ref);
             $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
             $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
-            $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
 
 			$object->sendtoid=0;
         }
@@ -716,7 +673,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $object->actionmsg=$langs->transnoentities("MemberDeletedInDolibarr",$object->ref);
             $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
             $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
-            $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
 
 			$object->sendtoid=0;
         }
@@ -732,7 +688,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
         	if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProjectCreatedInDolibarr",$object->ref);
         	$object->actionmsg=$langs->transnoentities("ProjectCreatedInDolibarr",$object->ref);
         	$object->actionmsg.="\n".$langs->transnoentities("Project").': '.$object->ref;
-        	$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
 
         	$object->sendtoid=0;
         }
@@ -746,7 +701,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProjectValidatedInDolibarr",$object->ref);
             $object->actionmsg=$langs->transnoentities("ProjectValidatedInDolibarr",$object->ref);
             $object->actionmsg.="\n".$langs->transnoentities("Project").': '.$object->ref;
-            $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
         
             $object->sendtoid=0;
         }
@@ -759,7 +713,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProjectModifiedInDolibarr",$object->ref);
             $object->actionmsg=$langs->transnoentities("ProjectModifieddInDolibarr",$object->ref);
             $object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref;
-            $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
         
             $object->sendtoid=0;
         }
@@ -775,7 +728,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
 			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskCreatedInDolibarr",$object->ref);
 			$object->actionmsg=$langs->transnoentities("TaskCreatedInDolibarr",$object->ref);
 			$object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref;
-			$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
 
 			$object->sendtoid=0;
 		}
@@ -789,7 +741,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
 			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskModifiedInDolibarr",$object->ref);
 			$object->actionmsg=$langs->transnoentities("TaskModifieddInDolibarr",$object->ref);
 			$object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref;
-			$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
 
 			$object->sendtoid=0;
 		}
@@ -803,18 +754,24 @@ class InterfaceActionsAuto extends DolibarrTriggers
 			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskDeletedInDolibarr",$object->ref);
 			$object->actionmsg=$langs->transnoentities("TaskDeletedInDolibarr",$object->ref);
 			$object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref;
-			$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
 
 			$object->sendtoid=0;
 		}
-
-		// The trigger was enabled but we are missing the implementation, let the log know
-		else
-		{
-			dol_syslog("Trigger '".$this->name."' for action '$action' was ran by ".__FILE__." but no handler found for this action.", LOG_WARNING);
-			return 0;
+		// TODO Merge all previous cases into this generic one
+		else {
+		    // Note: We are here only if $conf->global->MAIN_AGENDA_ACTIONAUTO_action is on (tested at begining of this function) 
+		    $langs->load("agenda");
+		    $langs->load("other");
+		    
+		    $object->actiontypecode='AC_OTH_AUTO';
+		    if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities($action."InDolibarr",$object->ref);
+		    $object->actionmsg=$langs->transnoentities($action."InDolibarr",$object->ref);
+		    
+		    $object->sendtoid=0;
 		}
-
+		
+		$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
+		
 		dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
 
         // Add entry in event table
diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php
index db2328cdfb4..9a2433994bd 100644
--- a/htdocs/expensereport/card.php
+++ b/htdocs/expensereport/card.php
@@ -444,14 +444,16 @@ if (empty($reshook))
    			$destinataire->fetch($object->fk_user_validator);
    			$emailTo = $destinataire->email;
     
-   			if ($emailTo)
-   			{
-   				// FROM
-   				$expediteur = new User($db);
-   				$expediteur->fetch($object->fk_user_author);
-   				$emailFrom = $expediteur->email;
+			// FROM
+			$expediteur = new User($db);
+			$expediteur->fetch($object->fk_user_author);
+			$emailFrom = $expediteur->email;
 
-    			// SUBJECT
+   			if ($emailFrom && $emailTo)
+   			{
+    			$filename=array(); $filedir=array(); $mimetype=array();
+   			    
+   			    // SUBJECT
     			$subject = $langs->transnoentities("ExpenseReportWaitingForReApproval");
     
     			// CONTENT
@@ -561,73 +563,83 @@ if (empty($reshook))
 
    			// CC
    			$emailCC = $conf->global->NDF_CC_EMAILS;
+            if (empty($emailTo)) $emailTo=$emailCC;
 
 			// FROM
    			$expediteur = new User($db);
    			$expediteur->fetch($object->fk_user_valid);
    			$emailFrom = $expediteur->email;
 
-			// SUBJECT
-   			$subject = $langs->transnoentities("ExpenseReportApproved");
-
-   			// CONTENT
-   			$link = $urlwithroot.'/expensereport/card.php?id='.$object->id;
-   			$message = $langs->transnoentities("ExpenseReportApprovedMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $link);
-
-   			// Rebuilt pdf
-			/*
-    		$object->setDocModel($user,"");
-    		$resultPDF = expensereport_pdf_create($db,$object,'',"",$langs);
-    
-    		if($resultPDF
-			{
-    			// ATTACHMENT
+   			if ($emailFrom && $emailTo)
+   			{
     			$filename=array(); $filedir=array(); $mimetype=array();
-    			array_push($filename,dol_sanitizeFileName($object->ref).".pdf");
-    			array_push($filedir, $conf->expensereport->dir_output."/".dol_sanitizeFileName($object->ref)."/".dol_sanitizeFileName($object->ref).".pdf");
-    			array_push($mimetype,"application/pdf");
-			}
-			*/
-
-        	// PREPARE SEND
-    		$mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename);
+   			    
+   			    // SUBJECT
+       			$subject = $langs->transnoentities("ExpenseReportApproved");
+    
+       			// CONTENT
+       			$link = $urlwithroot.'/expensereport/card.php?id='.$object->id;
+       			$message = $langs->transnoentities("ExpenseReportApprovedMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $link);
+    
+       			// Rebuilt pdf
+    			/*
+        		$object->setDocModel($user,"");
+        		$resultPDF = expensereport_pdf_create($db,$object,'',"",$langs);
+        
+        		if($resultPDF
+    			{
+        			// ATTACHMENT
+        			$filename=array(); $filedir=array(); $mimetype=array();
+        			array_push($filename,dol_sanitizeFileName($object->ref).".pdf");
+        			array_push($filedir, $conf->expensereport->dir_output."/".dol_sanitizeFileName($object->ref)."/".dol_sanitizeFileName($object->ref).".pdf");
+        			array_push($mimetype,"application/pdf");
+    			}
+    			*/
 
-   			if ($mailfile)
-   			{
-   				// SEND
-   				$result=$mailfile->sendfile();
-   				if ($result)
-   				{
-   					$mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($emailFrom,2),$mailfile->getValidAddress($emailTo,2));
-   					setEventMessages($mesg, null, 'mesgs');
-   					header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
-   					exit;
-   				}
-   				else
-   				{
-   					$langs->load("other");
-   					if ($mailfile->error)
-   					{
-   						$mesg='';
-   						$mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo);
-   						$mesg.='<br>'.$mailfile->error;
-   						setEventMessages($mesg, null, 'errors');
-   					}
-   					else
-   					{
-   						setEventMessages('No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', null, 'warnings');
-   					}
-   				}
+        		$mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename);
+    
+       			if ($mailfile)
+       			{
+       				// SEND
+       				$result=$mailfile->sendfile();
+       				if ($result)
+       				{
+       					$mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($emailFrom,2),$mailfile->getValidAddress($emailTo,2));
+       					setEventMessages($mesg, null, 'mesgs');
+       					header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
+       					exit;
+       				}
+       				else
+       				{
+       					$langs->load("other");
+       					if ($mailfile->error)
+       					{
+       						$mesg='';
+       						$mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo);
+       						$mesg.='<br>'.$mailfile->error;
+       						setEventMessages($mesg, null, 'errors');
+       					}
+       					else
+       					{
+       						setEventMessages('No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', null, 'warnings');
+       					}
+       				}
+       			}
+       			else
+       			{
+       				setEventMessages($mailfile->error,$mailfile->errors,'errors');
+       				$action='';
+       			}
    			}
-   			else
-   			{
-   				setEventMessages($mailfile->error,$mailfile->errors,'errors');
-   				$action='';
-   			}
-   		}
+    		else
+    		{
+    			setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings');
+    			$action='';
+    		}
+    	}
    		else
    		{
-   			setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings');
+   			setEventMessages($langs->trans("FailedtoSetToApprove"), null, 'warnings');
    			$action='';
    		}
    	}
@@ -677,68 +689,78 @@ if (empty($reshook))
     		$expediteur->fetch($object->fk_user_refuse);
     		$emailFrom = $expediteur->email;
     
-			// SUBJECT
-   			$subject = $langs->transnoentities("ExpenseReportRefused");
-
-   			// CONTENT
-   			$link = $urlwithroot.'/expensereport/card.php?id='.$object->id;
-			$message = $langs->transnoentities("ExpenseReportRefusedMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $_POST['detail_refuse'], $link);
-
-   			// Rebuilt pdf
-			/*
-    		$object->setDocModel($user,"");
-    		$resultPDF = expensereport_pdf_create($db,$object,'',"",$langs);
-    
-    		if($resultPDF
-			{
-    			// ATTACHMENT
+    		if ($emailFrom && $emailTo)
+    		{
     			$filename=array(); $filedir=array(); $mimetype=array();
-    			array_push($filename,dol_sanitizeFileName($object->ref).".pdf");
-    			array_push($filedir, $conf->expensereport->dir_output."/".dol_sanitizeFileName($object->ref)."/".dol_sanitizeFileName($object->ref).".pdf");
-    			array_push($mimetype,"application/pdf");
-			}
-			*/
+    		    
+    		    // SUBJECT
+       			$subject = $langs->transnoentities("ExpenseReportRefused");
     
-    		// PREPARE SEND
-    		$mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename);
+       			// CONTENT
+       			$link = $urlwithroot.'/expensereport/card.php?id='.$object->id;
+    			$message = $langs->transnoentities("ExpenseReportRefusedMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $_POST['detail_refuse'], $link);
     
-    		if ($mailfile)
-    		{
-    			// SEND
-    			$result=$mailfile->sendfile();
-    			if ($result)
-    			{
-    				$mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($emailFrom,2),$mailfile->getValidAddress($emailTo,2));
-    				setEventMessages($mesg, null, 'mesgs');
-    				header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
-    				exit;
-    			}
-    			else
+       			// Rebuilt pdf
+    			/*
+        		$object->setDocModel($user,"");
+        		$resultPDF = expensereport_pdf_create($db,$object,'',"",$langs);
+        
+        		if($resultPDF
     			{
-    				$langs->load("other");
-    				if ($mailfile->error)
-    				{
-    					$mesg='';
-    					$mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo);
-    					$mesg.='<br>'.$mailfile->error;
-    					setEventMessages($mesg, null, 'errors');
-    				}
-    				else
-    				{
-    					setEventMessages('No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', null, 'warnings');
-    				}
+        			// ATTACHMENT
+        			$filename=array(); $filedir=array(); $mimetype=array();
+        			array_push($filename,dol_sanitizeFileName($object->ref).".pdf");
+        			array_push($filedir, $conf->expensereport->dir_output."/".dol_sanitizeFileName($object->ref)."/".dol_sanitizeFileName($object->ref).".pdf");
+        			array_push($mimetype,"application/pdf");
     			}
-    		}
-    		else
-    		{
-    			setEventMessages($mailfile->error,$mailfile->errors,'errors');
-    			$action='';
-    		}
+    			*/
+        
+        		// PREPARE SEND
+        		$mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename);
+        
+        		if ($mailfile)
+        		{
+        			// SEND
+        			$result=$mailfile->sendfile();
+        			if ($result)
+        			{
+        				$mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($emailFrom,2),$mailfile->getValidAddress($emailTo,2));
+        				setEventMessages($mesg, null, 'mesgs');
+        				header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
+        				exit;
+        			}
+        			else
+        			{
+        				$langs->load("other");
+        				if ($mailfile->error)
+        				{
+        					$mesg='';
+        					$mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo);
+        					$mesg.='<br>'.$mailfile->error;
+        					setEventMessages($mesg, null, 'errors');
+        				}
+        				else
+        				{
+        					setEventMessages('No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', null, 'warnings');
+        				}
+        			}
+        		}
+        		else
+        		{
+        			setEventMessages($mailfile->error,$mailfile->errors,'errors');
+        			$action='';
+        		}
+        	}
+        	else
+        	{
+        		setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings');
+        		$action='';
+        	}
     	}
     	else
     	{
-    		setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings');
-    		$action='';
+    	    setEventMessages($langs->trans("FailedtoSetToDeny"), null, 'warnings');
+    	    $action='';
     	}
     }
     else
@@ -790,67 +812,77 @@ if (empty($reshook))
     			$expediteur->fetch($object->fk_user_cancel);
     			$emailFrom = $expediteur->email;
     
-				// SUBJECT
-				$subject = $langs->transnoentities("ExpenseReportCanceled");
-
-				// CONTENT
-				$link = $urlwithroot.'/expensereport/card.php?id='.$object->id;
-				$message = $langs->transnoentities("ExpenseReportCanceledMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $_POST['detail_cancel'], $link);
-
-				// Rebuilt pdf
-				/*
-				$object->setDocModel($user,"");
-				$resultPDF = expensereport_pdf_create($db,$object,'',"",$langs);
-		
-				if($resultPDF
-				{
-					// ATTACHMENT
-					$filename=array(); $filedir=array(); $mimetype=array();
-					array_push($filename,dol_sanitizeFileName($object->ref).".pdf");
-					array_push($filedir, $conf->expensereport->dir_output."/".dol_sanitizeFileName($object->ref)."/".dol_sanitizeFileName($object->ref).".pdf");
-					array_push($mimetype,"application/pdf");
-				}
-				*/
-
-    			// PREPARE SEND
-    			$mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename);
-    
-    			if ($mailfile)
+    			if ($emailFrom && $emailTo)
     			{
-    				// SEND
-    				$result=$mailfile->sendfile();
-    				if ($result)
+    			    $filename=array(); $filedir=array(); $mimetype=array();
+    			    
+    			    // SUBJECT
+    				$subject = $langs->transnoentities("ExpenseReportCanceled");
+    
+    				// CONTENT
+    				$link = $urlwithroot.'/expensereport/card.php?id='.$object->id;
+    				$message = $langs->transnoentities("ExpenseReportCanceledMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $_POST['detail_cancel'], $link);
+    
+    				// Rebuilt pdf
+    				/*
+    				$object->setDocModel($user,"");
+    				$resultPDF = expensereport_pdf_create($db,$object,'',"",$langs);
+    		
+    				if($resultPDF
     				{
-    					$mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($emailFrom,2),$mailfile->getValidAddress($emailTo,2));
-    					setEventMessages($mesg, null, 'mesgs');
-    					header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
-    					exit;
-    				}
-    				else
-    				{
-    					$langs->load("other");
-    					if ($mailfile->error)
-    					{
-    						$mesg='';
-    						$mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo);
-    						$mesg.='<br>'.$mailfile->error;
-    						setEventMessages($mesg, null, 'errors');
-    					}
-    					else
-    					{
-    						setEventMessages('No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', null, 'warnings');
-    					}
+    					// ATTACHMENT
+    					$filename=array(); $filedir=array(); $mimetype=array();
+    					array_push($filename,dol_sanitizeFileName($object->ref).".pdf");
+    					array_push($filedir, $conf->expensereport->dir_output."/".dol_sanitizeFileName($object->ref)."/".dol_sanitizeFileName($object->ref).".pdf");
+    					array_push($mimetype,"application/pdf");
     				}
+    				*/
+    
+        			// PREPARE SEND
+        			$mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename);
+        
+        			if ($mailfile)
+        			{
+        				// SEND
+        				$result=$mailfile->sendfile();
+        				if ($result)
+        				{
+        					$mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($emailFrom,2),$mailfile->getValidAddress($emailTo,2));
+        					setEventMessages($mesg, null, 'mesgs');
+        					header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
+        					exit;
+        				}
+        				else
+        				{
+        					$langs->load("other");
+        					if ($mailfile->error)
+        					{
+        						$mesg='';
+        						$mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo);
+        						$mesg.='<br>'.$mailfile->error;
+        						setEventMessages($mesg, null, 'errors');
+        					}
+        					else
+        					{
+        						setEventMessages('No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', null, 'warnings');
+        					}
+        				}
+        			}
+        			else
+        			{
+        				setEventMessages($mailfile->error,$mailfile->errors,'errors');
+        				$action='';
+        			}
     			}
     			else
     			{
-    				setEventMessages($mailfile->error,$mailfile->errors,'errors');
-    				$action='';
-    			}
+    			    setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings');
+    			    $action='';
+    			}        			
     		}
     		else
     		{
-    			setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings');
+    			setEventMessages($langs->trans("FailedToSetToCancel"), null, 'warnings');
     			$action='';
     		}
     	}
@@ -945,63 +977,73 @@ if (empty($reshook))
     		$expediteur->fetch($user->id);
     		$emailFrom = $expediteur->email;
     
-			// SUBJECT
-			$subject = $langs->transnoentities("ExpenseReportPaid");
-
-			// CONTENT
-			$link = $urlwithroot.'/expensereport/card.php?id='.$object->id;
-			$message = $langs->transnoentities("ExpenseReportPaidMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $link);
-    
-    		// CONTENT
-    		$message = "Bonjour {$destinataire->firstname},\n\n";
-    		$message.= "Votre note de frais \"{$object->ref}\" vient d'être payée.\n";
-    		$message.= "- Payeur : {$expediteur->firstname} {$expediteur->lastname}\n";
-    		$message.= "- Lien : {$dolibarr_main_url_root}/expensereport/card.php?id={$object->id}\n\n";
-    		$message.= "Bien cordialement,\n' SI";
-    
-    		// Generate pdf before attachment
-    		$object->setDocModel($user,"");
-    		$resultPDF = expensereport_pdf_create($db,$object,'',"",$langs);
-    
-    		// PREPARE SEND
-    		$mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename);
-    
-    		if ($mailfile)
+    		if ($emailFrom && $emailTo)
     		{
-    			// SEND
-				$result=$mailfile->sendfile();
-    			if ($result)
-    			{
-    				$mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($emailFrom,2),$mailfile->getValidAddress($emailTo,2));
-    				setEventMessages($mesg, null, 'mesgs');
-    				header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
-    				exit;
-    			}
-    			else
-    			{
-					$langs->load("other");
-    				if ($mailfile->error)
-    				{
-    					$mesg='';
-    					$mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo);
-    					$mesg.='<br>'.$mailfile->error;
-    					setEventMessages($mesg, null, 'errors');
-    				}
-    				else
-    				{
-    					setEventMessages('No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', null, 'warnings');
-    				}
-    			}
+    			$filename=array(); $filedir=array(); $mimetype=array();
+    		    
+    		    // SUBJECT
+    			$subject = $langs->transnoentities("ExpenseReportPaid");
+    
+    			// CONTENT
+    			$link = $urlwithroot.'/expensereport/card.php?id='.$object->id;
+    			$message = $langs->transnoentities("ExpenseReportPaidMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $link);
+        
+        		// CONTENT
+        		$message = "Bonjour {$destinataire->firstname},\n\n";
+        		$message.= "Votre note de frais \"{$object->ref}\" vient d'être payée.\n";
+        		$message.= "- Payeur : {$expediteur->firstname} {$expediteur->lastname}\n";
+        		$message.= "- Lien : {$dolibarr_main_url_root}/expensereport/card.php?id={$object->id}\n\n";
+        		$message.= "Bien cordialement,\n' SI";
+        
+        		// Generate pdf before attachment
+        		$object->setDocModel($user,"");
+        		$resultPDF = expensereport_pdf_create($db,$object,'',"",$langs);
+        
+        		// PREPARE SEND
+        		$mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename);
+        
+        		if ($mailfile)
+        		{
+        			// SEND
+    				$result=$mailfile->sendfile();
+        			if ($result)
+        			{
+        				$mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($emailFrom,2),$mailfile->getValidAddress($emailTo,2));
+        				setEventMessages($mesg, null, 'mesgs');
+        				header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
+        				exit;
+        			}
+        			else
+        			{
+    					$langs->load("other");
+        				if ($mailfile->error)
+        				{
+        					$mesg='';
+        					$mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo);
+        					$mesg.='<br>'.$mailfile->error;
+        					setEventMessages($mesg, null, 'errors');
+        				}
+        				else
+        				{
+        					setEventMessages('No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', null, 'warnings');
+        				}
+        			}
+        		}
+        		else
+        		{
+        			setEventMessages($mailfile->error,$mailfile->errors,'errors');
+        			$action='';
+        		}
     		}
     		else
     		{
-    			setEventMessages($mailfile->error,$mailfile->errors,'errors');
-    			$action='';
+    		    setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings');
+    		    $action='';
     		}
     	}
     	else
     	{
-    		setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings');
+    		setEventMessages($langs->trans("FailedToSetPaid"), null, 'warnings');
     		$action='';
     	}
     }
diff --git a/htdocs/install/mysql/data/llx_c_action_trigger.sql b/htdocs/install/mysql/data/llx_c_action_trigger.sql
index 9aadb0c083e..d25963e8c3a 100644
--- a/htdocs/install/mysql/data/llx_c_action_trigger.sql
+++ b/htdocs/install/mysql/data/llx_c_action_trigger.sql
@@ -78,6 +78,10 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value
 insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('FICHINTER_SENTBYMAIL','Intervention sent by mail','Executed when a intervention is sent by mail','ficheinter',35);
 insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PRODUCT_CREATE','Product or service created','Executed when a product or sevice is created','product',40);
 insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PRODUCT_DELETE','Product or service deleted','Executed when a product or sevice is deleted','product',42);
+insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_CREATE','Expense report created','Executed when an expense report is created','expensereport',201);
+insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_VALIDATE','Expense report validated','Executed when an expense report is validated','expensereport',202);
+insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_APPROVE','Expense report approved','Executed when an expense report is approved','expensereport',203);
+insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_PAYED','Expense report billed','Executed when an expense report is set as billed','expensereport',204);
 insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROJECT_VALIDATE','Project validation','Executed when a project is validated','project',141);
 insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROJECT_DELETE','Project deleted','Executed when a project is deleted','project',143);
 -- actions not enabled by default (no constant created for that) when we enable module agenda 
diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql
index b20da8b9b89..71f9a17273c 100644
--- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql
+++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql
@@ -42,10 +42,22 @@ ALTER TABLE llx_ecm_files ADD UNIQUE INDEX uk_ecm_files (filepath, filename, ent
 ALTER TABLE llx_ecm_files ADD INDEX idx_ecm_files_label (label);
 
 
+ALTER TABLE llx_holiday ADD COLUMN import_key				varchar(14);
+ALTER TABLE llx_holiday ADD COLUMN extraparams				varchar(255);	
+
+ALTER TABLE llx_expensereport ADD COLUMN import_key			varchar(14);
+ALTER TABLE llx_expensereport ADD COLUMN extraparams		varchar(255);	
+
+
 insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PRODUCT_CREATE','Product or service created','Executed when a product or sevice is created','product',30);
 insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PRODUCT_MODIFY','Product or service modified','Executed when a product or sevice is modified','product',30);
 insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PRODUCT_DELETE','Product or service deleted','Executed when a product or sevice is deleted','product',30);
 
+insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_CREATE','Expense report created','Executed when an expense report is created','expense_report',201);
+insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_VALIDATE','Expense report validated','Executed when an expense report is validated','expense_report',202);
+insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_APPROVE','Expense report approved','Executed when an expense report is approved','expense_report',203);
+insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_PAYED','Expense report billed','Executed when an expense report is set as billed','expense_report',204);
+
 ALTER TABLE llx_c_email_templates ADD COLUMN content_lines text;
 
 ALTER TABLE llx_loan ADD COLUMN fk_projet integer DEFAULT NULL;
@@ -111,6 +123,16 @@ INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (
 ALTER TABLE llx_paiementfourn ADD COLUMN model_pdf varchar(255);
 
 
+insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_CREATE','Expense report created','Executed when an expense report is created','expensereport',201);
+insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_VALIDATE','Expense report validated','Executed when an expense report is validated','expensereport',202);
+insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_APPROVE','Expense report approved','Executed when an expense report is approved','expensereport',203);
+insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_PAYED','Expense report billed','Executed when an expense report is set as billed','expensereport',204);
+
+insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('HOLIDAY_CREATE'  ,'Leave request created','Executed when a leave request is created','holiday',221);
+insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('HOLIDAY_VALIDATE','Leave request validated','Executed when a leave request is validated','holiday',222);
+insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('HOLIDAY_APPROVE' ,'Leave request approved','Executed when a leave request is approved','holiday',223);
+
+
 ALTER TABLE llx_societe_remise_except ADD COLUMN fk_invoice_supplier_line	integer;
 ALTER TABLE llx_societe_remise_except ADD COLUMN fk_invoice_supplier		integer;
 ALTER TABLE llx_societe_remise_except ADD COLUMN fk_invoice_supplier_source	integer;
diff --git a/htdocs/install/mysql/tables/llx_holiday.sql b/htdocs/install/mysql/tables/llx_holiday.sql
index 2a981444df3..2091dea9541 100644
--- a/htdocs/install/mysql/tables/llx_holiday.sql
+++ b/htdocs/install/mysql/tables/llx_holiday.sql
@@ -40,6 +40,8 @@ fk_user_cancel integer DEFAULT NULL,
 detail_refuse  varchar( 250 ) DEFAULT NULL,
 note_private   text,
 note_public    text,
-tms            timestamp
+tms            timestamp,
+import_key			varchar(14),
+extraparams			varchar(255)				-- for other parameters with json format
 ) 
 ENGINE=innodb;
-- 
GitLab