FIX sendEmailsReminder() function
This commit is contained in:
parent
c0f254d10c
commit
6562334f7b
@ -1994,66 +1994,73 @@ class ActionComm extends CommonObject
|
|||||||
|
|
||||||
if(!$error)
|
if(!$error)
|
||||||
{
|
{
|
||||||
//Select email template
|
|
||||||
$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)');
|
|
||||||
|
|
||||||
$res = $this->fetch($actionCommReminder->fk_actioncomm);
|
if ($actionCommReminder->dateremind <= dol_now())
|
||||||
|
|
||||||
if ($res > 0)
|
|
||||||
{
|
{
|
||||||
// PREPARE EMAIL
|
|
||||||
|
|
||||||
// Make substitution in email content
|
//Select email template
|
||||||
$substitutionarray = getCommonSubstitutionArray($langs, 0, '', $this);
|
$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)');
|
||||||
|
|
||||||
complete_substitutions_array($substitutionarray, $langs, $this);
|
$res = $this->fetch($actionCommReminder->fk_actioncomm);
|
||||||
|
|
||||||
// Content
|
if ($res > 0)
|
||||||
$sendContent = make_substitutions($langs->trans($arraymessage->content), $substitutionarray);
|
|
||||||
|
|
||||||
//Topic
|
|
||||||
$sendTopic = (!empty($arraymessage->topic)) ? $arraymessage->topic : html_entity_decode($langs->trans('EventReminder'));
|
|
||||||
|
|
||||||
// Recipient
|
|
||||||
$recipient = new User($this->db);
|
|
||||||
$res = $recipient->fetch($actionCommReminder->fk_user);
|
|
||||||
if ($res > 0 && !empty($recipient->email)) $to = $recipient->email;
|
|
||||||
else {
|
|
||||||
$this->errors[] = "Failed to load recipient";
|
|
||||||
$error++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sender
|
|
||||||
$from = $conf->global->MAIN_MAIL_EMAIL_FROM;
|
|
||||||
|
|
||||||
// Errors Recipient
|
|
||||||
$errors_to = $conf->global->MAIN_MAIL_ERRORS_TO;
|
|
||||||
|
|
||||||
// Mail Creation
|
|
||||||
$cMailFile = new CMailFile($sendTopic, $to, $from, $sendContent, array(), array(), array(), '', "", 0, 1, $errors_to, '', '', '', '', '');
|
|
||||||
|
|
||||||
// Sending Mail
|
|
||||||
if ($cMailFile->sendfile())
|
|
||||||
{
|
{
|
||||||
$actionCommReminder->status=$actionCommReminder::STATUS_DONE;
|
// PREPARE EMAIL
|
||||||
$res = $actionCommReminder->update($user);
|
|
||||||
if($res<0) {
|
// Make substitution in email content
|
||||||
$this->errors[] = "Failed to update status of ActionComm Reminder";
|
$substitutionarray = getCommonSubstitutionArray($langs, 0, '', $this);
|
||||||
|
|
||||||
|
complete_substitutions_array($substitutionarray, $langs, $this);
|
||||||
|
|
||||||
|
// Content
|
||||||
|
$sendContent = make_substitutions($langs->trans($arraymessage->content), $substitutionarray);
|
||||||
|
|
||||||
|
//Topic
|
||||||
|
$sendTopic = (!empty($arraymessage->topic)) ? $arraymessage->topic : html_entity_decode($langs->trans('EventReminder'));
|
||||||
|
|
||||||
|
// Recipient
|
||||||
|
$recipient = new User($this->db);
|
||||||
|
$res = $recipient->fetch($actionCommReminder->fk_user);
|
||||||
|
if ($res > 0 && !empty($recipient->email)) $to = $recipient->email;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->errors[] = "Failed to load recipient";
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sender
|
||||||
|
$from = $conf->global->MAIN_MAIL_EMAIL_FROM;
|
||||||
|
|
||||||
|
// Errors Recipient
|
||||||
|
$errors_to = $conf->global->MAIN_MAIL_ERRORS_TO;
|
||||||
|
|
||||||
|
// Mail Creation
|
||||||
|
$cMailFile = new CMailFile($sendTopic, $to, $from, $sendContent, array(), array(), array(), '', "", 0, 1, $errors_to, '', '', '', '', '');
|
||||||
|
|
||||||
|
// Sending Mail
|
||||||
|
if ($cMailFile->sendfile())
|
||||||
|
{
|
||||||
|
$actionCommReminder->status = $actionCommReminder::STATUS_DONE;
|
||||||
|
$res = $actionCommReminder->update($user);
|
||||||
|
if ($res < 0)
|
||||||
|
{
|
||||||
|
$this->errors[] = "Failed to update status of ActionComm Reminder";
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
else $nbMailSend++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$errorsMsg[] = $cMailFile->error.' : '.$to;
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
else $nbMailSend++;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$errorsMsg[] = $cMailFile->error.' : '.$to;
|
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
$error++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user