From 6124c60157c18af7bb17a6796e0f0db988e4ff3d Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@destailleur.fr>
Date: Mon, 3 Oct 2016 00:39:07 +0200
Subject: [PATCH] FIX Nber of attached files were not reported in event report
 of email sent

---
 htdocs/core/actions_sendmails.inc.php                       | 6 +++---
 .../triggers/interface_50_modAgenda_ActionsAuto.class.php   | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php
index dfc73105255..3ac6fb36289 100644
--- a/htdocs/core/actions_sendmails.inc.php
+++ b/htdocs/core/actions_sendmails.inc.php
@@ -103,12 +103,11 @@ if (GETPOST('removAll'))
 if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_POST['removAll'] && ! $_POST['removedfile'] && ! $_POST['cancel'] && !$_POST['modelselected'])
 {
 	$trackid = GETPOST('trackid','aZ09');
-
+	$subject='';$actionmsg='';$actionmsg2='';
+	
     if (! empty($conf->dolimail->enabled)) $langs->load("dolimail@dolimail");
 	$langs->load('mails');
 
-	$subject='';$actionmsg='';$actionmsg2='';
-
 	if (is_object($object))
 	{
     	$result=$object->fetch($id);
@@ -323,6 +322,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
 					$object->actiontypecode	= $actiontypecode;
 					$object->actionmsg		= $actionmsg;  // Long text
 					$object->actionmsg2		= $actionmsg2; // Short text
+					$object->trackid        = $trackid;
 					$object->fk_element		= $object->id;
 					$object->elementtype	= $object->element;
 
diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php
index 2f9c1a132d5..72760e7e72f 100644
--- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php
+++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php
@@ -756,9 +756,9 @@ class InterfaceActionsAuto extends DolibarrTriggers
         // Add entry in event table
 		$now=dol_now();
 
-		if (isset($_SESSION['listofnames']))
+		if (isset($_SESSION['listofnames-'.$object->trackid]))
 		{
-			$attachs=$_SESSION['listofnames'];
+			$attachs=$_SESSION['listofnames-'.$object->trackid];
 			if ($attachs && strpos($action,'SENTBYMAIL'))
 			{
                 $object->actionmsg=dol_concatdesc($object->actionmsg, "\n".$langs->transnoentities("AttachedFiles").': '.$attachs);
-- 
GitLab