Merge pull request #15893 from atm-lena/FIX_issue_15629

FIX #15629
This commit is contained in:
Laurent Destailleur 2021-01-06 20:34:31 +01:00 committed by GitHub
commit 679948e207
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -251,11 +251,21 @@ class InterfaceTicketEmail extends DolibarrTriggers
if (empty($conf->global->TICKET_DISABLE_CUSTOMER_MAILS) && empty($object->context['disableticketemail']) && $object->notify_tiers_at_create)
{
$sendto = '';
if (empty($user->socid) && empty($user->email)) {
$object->fetch_thirdparty();
$sendto = $object->thirdparty->email;
} else {
$sendto = $user->email;
//if contact selected send to email's contact else send to email's thirdparty
$contactid = GETPOST('contactid', 'alpha');
if(!empty($contactid)) {
$contact = new Contact($this->db);
$res = $contact->fetch($contactid);
}
if($res > 0 && !empty($contact->email) && !empty($contact->statut)) {
$sendto = $contact->email;
} elseif (!empty($object->fk_soc)) {
$object->fetch_thirdparty();
$sendto = $object->thirdparty->email;
}
if ($sendto) {