FIX sendEmailsReminder() function

This commit is contained in:
atm-lena 2020-08-28 09:37:18 +02:00
parent c0f254d10c
commit 6562334f7b

View File

@ -1994,6 +1994,10 @@ class ActionComm extends CommonObject
if(!$error) if(!$error)
{ {
if ($actionCommReminder->dateremind <= dol_now())
{
//Select email template //Select email template
$formmail = new FormMail($this->db); $formmail = new FormMail($this->db);
$arraymessage = $formmail->getEMailTemplate($this->db, 'actioncomm_send', $user, $langs, (!empty($actionCommReminder->fk_email_template)) ? $actionCommReminder->fk_email_template : 0, 1, '(SendingReminderActionComm)'); $arraymessage = $formmail->getEMailTemplate($this->db, 'actioncomm_send', $user, $langs, (!empty($actionCommReminder->fk_email_template)) ? $actionCommReminder->fk_email_template : 0, 1, '(SendingReminderActionComm)');
@ -2019,7 +2023,8 @@ class ActionComm extends CommonObject
$recipient = new User($this->db); $recipient = new User($this->db);
$res = $recipient->fetch($actionCommReminder->fk_user); $res = $recipient->fetch($actionCommReminder->fk_user);
if ($res > 0 && !empty($recipient->email)) $to = $recipient->email; if ($res > 0 && !empty($recipient->email)) $to = $recipient->email;
else { else
{
$this->errors[] = "Failed to load recipient"; $this->errors[] = "Failed to load recipient";
$error++; $error++;
} }
@ -2036,9 +2041,10 @@ class ActionComm extends CommonObject
// Sending Mail // Sending Mail
if ($cMailFile->sendfile()) if ($cMailFile->sendfile())
{ {
$actionCommReminder->status=$actionCommReminder::STATUS_DONE; $actionCommReminder->status = $actionCommReminder::STATUS_DONE;
$res = $actionCommReminder->update($user); $res = $actionCommReminder->update($user);
if($res<0) { if ($res < 0)
{
$this->errors[] = "Failed to update status of ActionComm Reminder"; $this->errors[] = "Failed to update status of ActionComm Reminder";
$error++; $error++;
} }
@ -2056,6 +2062,7 @@ class ActionComm extends CommonObject
} }
} }
} }
}
} else { } else {
$error++; $error++;
} }