Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix - Reuniones - "Run Email Reminder Notifications" no se ejecuta al eliminar una persona #406

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 28 additions & 11 deletions modules/Reminders/Reminder.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,18 @@ public static function sendEmailReminders(EmailReminder $emailReminder, Administ
foreach ($reminders as $reminderId => $reminder) {
$recipients = self::getEmailReminderInviteesRecipients($reminderId, $checkDecline);
$eventBean = BeanFactory::getBean($reminder->related_event_module, $reminder->related_event_module_id);
if ($eventBean && $emailReminder->sendReminders($eventBean, $admin, $recipients)) {
$reminder->email_sent = 1;
$reminder->save();

// STIC-Custom 20240926 ART - “Run Email Reminder Notifications” does not run when deleting a person
// https://github.com/SinergiaTIC/SinergiaCRM/pull/406

// Current date added to compare with meeting start date to avoid sending past reminders
$dateNow = date('d/m/Y H:i');
if($eventBean->date_start > $dateNow || $eventBean->date_start == $dateNow){
// END STIC-Custom
if ($eventBean && $emailReminder->sendReminders($eventBean, $admin, $recipients)) {
$reminder->email_sent = 1;
$reminder->save();
}
}
}
}
Expand All @@ -238,14 +247,22 @@ private static function getEmailReminderInviteesRecipients($reminderId, $checkDe
$inviteeModuleId = $invitee->related_invitee_module_id;
$personBean = BeanFactory::getBean($inviteeModule, $inviteeModuleId);
// The original email reminders check the accept_status field in related users/leads/contacts etc. and filtered these users who not decline this event.
if ($checkDecline && !self::isDecline($event, $personBean)) {
if (!empty($personBean->email1)) {
$arr = array(
'type' => $inviteeModule,
'name' => $personBean->full_name,
'email' => $personBean->email1,
);
$emails[] = $arr;

// STIC-Custom 20240926 ART - “Run Email Reminder Notifications” does not run when deleting a person
// https://github.com/SinergiaTIC/SinergiaCRM/pull/406

// Prevent a deleted contact, user, etc. from being deleted in order for the task to run
if($personBean != false) {
// END STIC-Custom
if ($checkDecline && !self::isDecline($event, $personBean)) {
if (!empty($personBean->email1)) {
$arr = array(
'type' => $inviteeModule,
'name' => $personBean->full_name,
'email' => $personBean->email1,
);
$emails[] = $arr;
}
}
}
}
Expand Down
Loading