NEW : Can send email to multiple destinaries from mailform
This commit is contained in:
parent
eb70d6eea1
commit
5ec01b3175
@ -160,24 +160,33 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
|
|||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
|
$receiver=$_POST['receiver'];
|
||||||
|
$sendto_array=array();
|
||||||
|
|
||||||
if (trim($_POST['sendto']))
|
if (trim($_POST['sendto']))
|
||||||
{
|
{
|
||||||
// Recipient is provided into free text
|
// Recipient is provided into free text
|
||||||
$sendto = trim($_POST['sendto']);
|
$sendto = trim($_POST['sendto']);
|
||||||
$sendtoid = 0;
|
$sendtoid = array();
|
||||||
}
|
}
|
||||||
elseif ($_POST['receiver'] != '-1')
|
elseif (count($receiver)>0)
|
||||||
{
|
{
|
||||||
// Recipient was provided from combo list
|
foreach($receiver as $key=>$val) {
|
||||||
if ($_POST['receiver'] == 'thirdparty') // Id of third party
|
// Recipient was provided from combo list
|
||||||
{
|
if ($val == 'thirdparty') // Id of third party
|
||||||
$sendto = $thirdparty->name.' <'.$thirdparty->email.'>';
|
{
|
||||||
$sendtoid = 0;
|
$sendto_array[] = $thirdparty->name.' <'.$thirdparty->email.'>';
|
||||||
|
$sendtoid = array();
|
||||||
|
}
|
||||||
|
else // Id du contact
|
||||||
|
{
|
||||||
|
$sendto_array[] = $thirdparty->contact_get_property((int) $val,'email');
|
||||||
|
$sendtoid[] = $val;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else // Id du contact
|
|
||||||
{
|
if (count($sendto_array)>0) {
|
||||||
$sendto = $thirdparty->contact_get_property((int) $_POST['receiver'],'email');
|
$sendto=implode(',',$sendto_array);
|
||||||
$sendtoid = $_POST['receiver'];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (trim($_POST['sendtocc']))
|
if (trim($_POST['sendtocc']))
|
||||||
@ -339,22 +348,45 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
|
|||||||
// Initialisation of datas
|
// Initialisation of datas
|
||||||
if (is_object($object))
|
if (is_object($object))
|
||||||
{
|
{
|
||||||
$object->socid = $sendtosocid; // To link to a company
|
//multiple contact sends
|
||||||
$object->sendtoid = $sendtoid; // To link to a contact/address
|
if (count($sendtoid) >0) {
|
||||||
$object->actiontypecode = $actiontypecode;
|
foreach($sendtoid as $val_id) {
|
||||||
$object->actionmsg = $actionmsg; // Long text
|
$object->socid = $sendtosocid; // To link to a company
|
||||||
$object->actionmsg2 = $actionmsg2; // Short text
|
$object->sendtoid = $val_id; // To link to a contact/address
|
||||||
$object->trackid = $trackid;
|
$object->actiontypecode = $actiontypecode;
|
||||||
$object->fk_element = $object->id;
|
$object->actionmsg = $actionmsg; // Long text
|
||||||
$object->elementtype = $object->element;
|
$object->actionmsg2 = $actionmsg2; // Short text
|
||||||
|
$object->trackid = $trackid;
|
||||||
|
$object->fk_element = $object->id;
|
||||||
|
$object->elementtype = $object->element;
|
||||||
|
|
||||||
// Call of triggers
|
// Call of triggers
|
||||||
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||||
$interface=new Interfaces($db);
|
$interface=new Interfaces($db);
|
||||||
$result=$interface->run_triggers($trigger_name,$object,$user,$langs,$conf);
|
$result=$interface->run_triggers($trigger_name,$object,$user,$langs,$conf);
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
$error++; $errors=$interface->errors;
|
$error++; $errors=$interface->errors;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//Thirdparty send
|
||||||
|
$object->socid = $sendtosocid; // To link to a company
|
||||||
|
$object->sendtoid = 0; // To link to a contact/address
|
||||||
|
$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;
|
||||||
|
|
||||||
|
// Call of triggers
|
||||||
|
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||||
|
$interface=new Interfaces($db);
|
||||||
|
$result=$interface->run_triggers($trigger_name,$object,$user,$langs,$conf);
|
||||||
|
if ($result < 0) {
|
||||||
|
$error++; $errors=$interface->errors;
|
||||||
|
}
|
||||||
|
}
|
||||||
// End call of triggers
|
// End call of triggers
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -521,7 +521,7 @@ class FormMail extends Form
|
|||||||
if (! empty($this->withto) && is_array($this->withto))
|
if (! empty($this->withto) && is_array($this->withto))
|
||||||
{
|
{
|
||||||
if (! empty($this->withtofree)) $out.= " ".$langs->trans("or")." ";
|
if (! empty($this->withtofree)) $out.= " ".$langs->trans("or")." ";
|
||||||
$out.= $form->selectarray("receiver", $this->withto, GETPOST("receiver"), 1, 0, 0, '', 0, 0, 0, '', '', 0, '', $disablebademails);
|
$out.= $form->multiselectarray("receiver", $this->withto, GETPOST("receiver"), null, null, null,null, "90%");
|
||||||
}
|
}
|
||||||
if (isset($this->withtosocid) && $this->withtosocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method.
|
if (isset($this->withtosocid) && $this->withtosocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method.
|
||||||
{
|
{
|
||||||
@ -533,7 +533,7 @@ class FormMail extends Form
|
|||||||
$liste[$key]=$value;
|
$liste[$key]=$value;
|
||||||
}
|
}
|
||||||
if ($this->withtofree) $out.= " ".$langs->trans("or")." ";
|
if ($this->withtofree) $out.= " ".$langs->trans("or")." ";
|
||||||
$out.= $form->selectarray("receiver", $liste, GETPOST("receiver"), 1, 0, 0, '', 0, 0, 0, '', '', 0, '', $disablebademails);
|
$out.= $form->multiselectarray("receiver", $liste, GETPOST("receiver"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$out.= "</td></tr>\n";
|
$out.= "</td></tr>\n";
|
||||||
|
|||||||
@ -2026,7 +2026,7 @@ class Societe extends CommonObject
|
|||||||
if ($this->email && $addthirdparty)
|
if ($this->email && $addthirdparty)
|
||||||
{
|
{
|
||||||
if (empty($this->name)) $this->name=$this->nom;
|
if (empty($this->name)) $this->name=$this->nom;
|
||||||
$contact_emails['thirdparty']=$langs->trans("ThirdParty").': '.dol_trunc($this->name,16)." <".$this->email.">";
|
$contact_emails['thirdparty']=$langs->trans("ThirdParty").': '.dol_trunc($this->name,16)." (".$this->email.")";
|
||||||
}
|
}
|
||||||
return $contact_emails;
|
return $contact_emails;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user