diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php
index 65f9de24496..983e9600c92 100644
--- a/htdocs/adherents/class/adherent.class.php
+++ b/htdocs/adherents/class/adherent.class.php
@@ -158,6 +158,7 @@ class Adherent extends CommonObject
$from=$conf->email_from;
if (! empty($conf->global->ADHERENT_MAIL_FROM)) $from=$conf->global->ADHERENT_MAIL_FROM;
+ // Send email (substitutionarray must be done just before this)
include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
$mailfile = new CMailFile($subjecttosend, $this->email, $from, $texttosend, $filename_list, $mimetype_list, $mimefilename_list, $addr_cc, $addr_bcc, $deliveryreceipt, $msgishtml);
if ($mailfile->sendfile())
diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php
index dadf7b476ee..279c65fa204 100644
--- a/htdocs/admin/mails.php
+++ b/htdocs/admin/mails.php
@@ -46,13 +46,18 @@ if ($action == 'test' || $action == 'send')
}
$substitutionarrayfortest=array(
-'__LOGIN__' => $user->login,
-'__ID__' => 'TESTIdRecord',
-'__EMAIL__' => 'TESTEMail',
-'__LASTNAME__' => 'TESTLastname',
-'__FIRSTNAME__' => 'TESTFirstname',
-'__SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$usersignature:''),
-//'__PERSONALIZED__' => 'TESTPersonalized' // Hiden because not used yet
+'__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT,
+'__ID__' => 'RecipientIdRecord',
+//'__EMAIL__' => 'RecipientEMail', // Done into actions_sendmails
+'__CHECK_READ__' => (is_object($object) && is_object($object->thirdparty))?'
':'',
+'__SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$usersignature:''), // Done into actions_sendmails
+'__LOGIN__' => 'RecipientLogin',
+'__LASTNAME__' => 'RecipientLastname',
+'__FIRSTNAME__' => 'RecipientFirstname',
+'__ADDRESS__'=> 'RecipientAddress',
+'__ZIP__'=> 'RecipientZip',
+'__TOWN_'=> 'RecipientTown',
+'__COUNTRY__'=> 'RecipientCountry'
);
complete_substitutions_array($substitutionarrayfortest, $langs);
diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php
index 0d4a6c6d80c..e424fe0376b 100644
--- a/htdocs/core/actions_massactions.inc.php
+++ b/htdocs/core/actions_massactions.inc.php
@@ -82,7 +82,7 @@ if (! $error && $massaction == 'confirm_presend')
$result=$objecttmp->fetch($toselectid);
if ($result > 0)
{
- $listoinvoicesid[$toselectid]=$toselectid;
+ $listofobjectid[$toselectid]=$toselectid;
$thirdpartyid=$objecttmp->fk_soc?$objecttmp->fk_soc:$objecttmp->socid;
$listofobjectthirdparties[$thirdpartyid]=$thirdpartyid;
$listofobjectref[$thirdpartyid][$toselectid]=$objecttmp;
@@ -169,7 +169,7 @@ if (! $error && $massaction == 'confirm_presend')
//var_dump($listofobjectref);exit;
$attachedfiles=array('paths'=>array(), 'names'=>array(), 'mimes'=>array());
- $listofqualifiedinvoice=array();
+ $listofqualifiedid=array();
$listofqualifiedref=array();
foreach($listofobjectref[$thirdpartyid] as $objectid => $object)
{
@@ -223,7 +223,7 @@ if (! $error && $massaction == 'confirm_presend')
);
}
- $listofqualifiedinvoice[$objectid]=$object;
+ $listofqualifiedid[$objectid]=$object;
$listofqualifiedref[$objectid]=$object->ref;
}
else
@@ -238,8 +238,8 @@ if (! $error && $massaction == 'confirm_presend')
//var_dump($listofqualifiedref);
}
- // Loop on each qualified invoice of the thirdparty
- if (count($listofqualifiedinvoice) > 0)
+ // Loop on each qualified objects of the thirdparty
+ if (count($listofqualifiedid) > 0)
{
$langs->load("commercial");
@@ -266,17 +266,35 @@ if (! $error && $massaction == 'confirm_presend')
$subject = GETPOST('subject');
$message = GETPOST('message');
$sendtocc = GETPOST('sentocc');
- $sendtobcc = (empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO)?'':$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO);
+ $sendtobcc = '';
+ if ($objectclass == 'Propale') $sendtocc = (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO)?'':$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO);
+ if ($objectclass == 'Commande') $sendtocc = (empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO)?'':$conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO);
+ if ($objectclass == 'Facture') $sendtocc = (empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO)?'':$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO);
+ if ($objectclass == 'Supplier_Proposal') $sendtocc = (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO)?'':$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO);
+ if ($objectclass == 'CommandeFournisseur') $sendtocc = (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO)?'':$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO);
+ if ($objectclass == 'FactureFournisseur') $sendtocc = (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO)?'':$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO);
+
$substitutionarray=array(
- '__ID__' => join(', ',array_keys($listofqualifiedinvoice)),
+ '__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT,
+ '__ID__' => join(', ',array_keys($listofqualifiedid)),
'__EMAIL__' => $thirdparty->email,
'__CHECK_READ__' => '
',
'__FACREF__' => join(', ',$listofqualifiedref), // For backward compatibility
'__ORDERREF__' => join(', ',$listofqualifiedref), // For backward compatibility
'__PROPREF__' => join(', ',$listofqualifiedref), // For backward compatibility
'__REF__' => join(', ',$listofqualifiedref),
- '__REFCLIENT__' => $thirdparty->name
+ '__REFCLIENT__' => $thirdparty->name,
+ '__SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?dol_string_nohtmltag($user->signature):'')
+ /* not available on all object
+ /'__FIRSTNAME__'=>(is_object($object)?$object->firstname:''),
+ '__LASTNAME__'=>(is_object($object)?$object->lastname:''),
+ '__FULLNAME__'=>(is_object($object)?$object->getFullName($langs):''),
+ '__ADDRESS__'=>(is_object($object)?$object->address:''),
+ '__ZIP__'=>(is_object($object)?$object->zip:''),
+ '__TOWN_'=>(is_object($object)?$object->town:''),
+ '__COUNTRY__'=>(is_object($object)?$object->country:''),
+ */
);
$subject=make_substitutions($subject, $substitutionarray);
@@ -288,7 +306,7 @@ if (! $error && $massaction == 'confirm_presend')
//var_dump($filepath);
- // Send mail
+ // Send mail (substitutionarray must be done just before this)
require_once(DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php');
$mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,$sendtobcc,$deliveryreceipt,-1);
if ($mailfile->error)
@@ -305,7 +323,7 @@ if (! $error && $massaction == 'confirm_presend')
$error=0;
// Insert logs into agenda
- foreach($listofqualifiedinvoice as $invid => $object)
+ foreach($listofqualifiedid as $objid => $object)
{
/*if ($objectclass == 'Propale') $actiontypecode='AC_PROP';
if ($objectclass == 'Commande') $actiontypecode='AC_COM';
@@ -328,7 +346,7 @@ if (! $error && $massaction == 'confirm_presend')
$object->sendtoid = 0;
$object->actionmsg = $actionmsg; // Long text
$object->actionmsg2 = $actionmsg2; // Short text
- $object->fk_element = $invid;
+ $object->fk_element = $objid;
$object->elementtype = $object->element;
// Appel des triggers
@@ -403,7 +421,7 @@ if (! $error && $massaction == "builddoc" && $permtoread && ! GETPOST('button_se
$result=$objecttmp->fetch($toselectid);
if ($result > 0)
{
- $listoinvoicesid[$toselectid]=$toselectid;
+ $listofobjectid[$toselectid]=$toselectid;
$thirdpartyid=$objecttmp->fk_soc?$objecttmp->fk_soc:$objecttmp->socid;
$listofobjectthirdparties[$thirdpartyid]=$thirdpartyid;
$listofobjectref[$toselectid]=$objecttmp->ref;
diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php
index a796a94c68c..f18827bdd67 100644
--- a/htdocs/core/actions_sendmails.inc.php
+++ b/htdocs/core/actions_sendmails.inc.php
@@ -344,7 +344,29 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
}
}
- // Send mail
+
+ $substitutionarray=array(
+ '__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT,
+ '__ID__' => (is_object($object)?$object->id:''),
+ '__EMAIL__' => $sendto,
+ '__CHECK_READ__' => (is_object($object) && is_object($object->thirdparty))?'
':'',
+ '__REF__' => (is_object($object)?$object->ref:''),
+ '__SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?dol_string_nohtmltag($user->signature):'')
+ /* not available on all object
+ /'__FIRSTNAME__'=>(is_object($object)?$object->firstname:''),
+ '__LASTNAME__'=>(is_object($object)?$object->lastname:''),
+ '__FULLNAME__'=>(is_object($object)?$object->getFullName($langs):''),
+ '__ADDRESS__'=>(is_object($object)?$object->address:''),
+ '__ZIP__'=>(is_object($object)?$object->zip:''),
+ '__TOWN_'=>(is_object($object)?$object->town:''),
+ '__COUNTRY__'=>(is_object($object)?$object->country:''),
+ */
+ );
+
+ $subject=make_substitutions($subject, $substitutionarray);
+ $message=make_substitutions($message, $substitutionarray);
+
+ // Send mail (substitutionarray must be done just before this)
$mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,$sendtobcc,$deliveryreceipt,-1,'','',$trackid);
if ($mailfile->error)
{
diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang
index bd52f5dcaa2..9179b8eddb7 100644
--- a/htdocs/langs/en_US/other.lang
+++ b/htdocs/langs/en_US/other.lang
@@ -71,7 +71,7 @@ MaxSize=Maximum size
AttachANewFile=Attach a new file/document
LinkedObject=Linked object
NbOfActiveNotifications=Number of notifications (nb of recipient emails)
-PredefinedMailTest=This is a test mail.\nThe two lines are separated by a carriage return.\n\n__SIGNATURE__
+PredefinedMailTest=This is a test mail sent to __EMAIL__.\nThe two lines are separated by a carriage return.\n\n__SIGNATURE__
PredefinedMailTestHtml=This is a test mail (the word test must be in bold).
The two lines are separated by a carriage return.
__SIGNATURE__
PredefinedMailContentSendInvoice=__CONTACTCIVNAME__\n\nYou will find here the invoice __REF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__
PredefinedMailContentSendInvoiceReminder=__CONTACTCIVNAME__\n\nWe would like to warn you that the invoice __REF__ seems to not being payed. So this is the invoice in attachment again, as a reminder.\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__