diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index a43127c9a32..282f0cd893b 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -409,6 +409,13 @@ if (empty($reshook)) } } } + + // Actions to send emails + $trigger_name='CONTACT_SENTBYMAIL'; + $paramname='id'; + $mode='emailfromcontact'; + $trackid='con'.$object->id; + include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; } @@ -1252,7 +1259,18 @@ else $reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { - if ($user->rights->societe->contact->creer) + if (! empty($object->email)) + { + $langs->load("mails"); + print '
'.$langs->trans('SendMail').'
'; + } + else + { + $langs->load("mails"); + print '
'.$langs->trans('SendMail').'
'; + } + + if ($user->rights->societe->contact->creer) { print ''.$langs->trans('Modify').''; } @@ -1281,6 +1299,14 @@ else } print ""; + + // Presend form + $modelmail='contact'; + $defaulttopic='Information'; + $diroutput = $conf->contact->dir_output; + $trackid = 'con'.$object->id; + + include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; } } diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index 61c4b636758..3ba9a3de6ec 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -113,7 +113,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $result=$object->fetch($id); $sendtosocid=0; // Thirdparty on object - if (method_exists($object,"fetch_thirdparty") && ! in_array($object->element, array('societe','member','user','expensereport'))) + if (method_exists($object,"fetch_thirdparty") && ! in_array($object->element, array('societe','member','user','expensereport', 'contact'))) { $result=$object->fetch_thirdparty(); if ($object->element == 'user' && $result == 0) $result=1; // Even if not found, we consider ok @@ -130,6 +130,11 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $thirdparty=$object; if ($thirdparty->id > 0) $sendtosocid=$thirdparty->id; } + else if ($object->element == 'contact') + { + $contact=$object; + if ($contact->id > 0) $sendtosocid=$contact->fetch_thirdparty()->id; + } else dol_print_error('','Use actions_sendmails.in.php for an element/object that is not supported'); if (is_object($hookmanager)) @@ -171,6 +176,11 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO { $tmparray[] = dol_string_nospecial($thirdparty->name, ' ', array(",")).' <'.$thirdparty->email.'>'; } + // Recipient was provided from combo list + elseif ($val == 'contact') // Id of contact + { + $tmparray[] = dol_string_nospecial($contact->name, ' ', array(",")).' <'.$contact->email.'>'; + } elseif ($val) // Id du contact { $tmparray[] = $thirdparty->contact_get_property((int) $val,'email'); @@ -215,6 +225,11 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO { $tmparray[] = dol_string_nospecial($thirdparty->name, ' ', array(",")).' <'.$thirdparty->email.'>'; } + // Recipient was provided from combo list + elseif ($val == 'contact') // Id of contact + { + $tmparray[] = dol_string_nospecial($contact->name, ' ', array(",")).' <'.$contact->email.'>'; + } elseif ($val) // Id du contact { $tmparray[] = $thirdparty->contact_get_property((int) $val,'email'); diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php index 0d1fd84923c..db3514d7778 100644 --- a/htdocs/core/tpl/card_presend.tpl.php +++ b/htdocs/core/tpl/card_presend.tpl.php @@ -140,6 +140,10 @@ if ($action == 'presend') $liste[$key] = $value; } } + elseif ($object->element == 'contact') + { + $liste['contact'] = $object->getFullName($langs)." <".$object->email.">"; + } elseif ($object->element == 'user' || $object->element == 'member') { $liste['thirdparty'] = $object->getFullName($langs)." <".$object->email.">";