From f57325237aea5b77db1e013d46b5965f49f39710 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Thu, 27 Aug 2020 12:30:59 +0200 Subject: [PATCH] WIP : sendEmailsReminder() --- htdocs/comm/action/class/actioncomm.class.php | 19 ++++++++++++++++++- htdocs/langs/en_US/members.lang | 1 + 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 1e860217d03..f97a01f67e9 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -28,6 +28,8 @@ */ require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + /** @@ -1949,7 +1951,7 @@ class ActionComm extends CommonObject */ public function sendEmailsReminder() { - global $conf, $langs; + global $conf, $langs, $user; $error = 0; $this->output = ''; @@ -1976,6 +1978,21 @@ class ActionComm extends CommonObject // TODO Scan events of type 'email' into table llx_actioncomm_reminder with status todo, send email, then set status to done + $sql = "SELECT rowid as id, fk_email_template FROM ".MAIN_DB_PREFIX."actioncomm_reminder WHERE typeremind = 'email'"; + $resql = $this->db->query($sql); + + if($resql){ + while($obj = $this->db->fetch_object($resql)){ + $formmail = new FormMail($this->db); + + $arraymessage = $formmail->getEMailTemplate($this->db, 'actioncomm_send', $user, $langs, (!empty($obj->fk_email_template)) ? $obj->fk_email_template : 0, 1, '(SendingReminderActionComm)'); + + } + } else { + $error++; + } + + // Delete also very old past events (we do not keep more than 1 month record in past) $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_reminder WHERE dateremind < '".$this->db->jdate($now - (3600 * 24 * 32))."'"; $this->db->query($sql); diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index 5ef946ddf67..2f126b11fdf 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -117,6 +117,7 @@ SendingEmailOnMemberValidation=Sending email on new member validation SendingEmailOnNewSubscription=Sending email on new subscription SendingReminderForExpiredSubscription=Sending reminder for expired subscriptions SendingEmailOnCancelation=Sending email on cancelation +SendingReminderActionComm=Sending reminder for agenda event # Topic of email templates YourMembershipRequestWasReceived=Your membership was received. YourMembershipWasValidated=Your membership was validated