From: yashodha Date: Tue, 27 Oct 2015 09:46:30 +0000 (+0530) Subject: CRM-17028: Yearly and Monthly Repeat Reminders send on every cron for 24 hours X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=3fc9bc80ee64f94c1c55b7e222d91fce9e02a861;p=civicrm-core.git CRM-17028: Yearly and Monthly Repeat Reminders send on every cron for 24 hours ---------------------------------------- * CRM-17028: Yearly and Monthly Repeat Reminders send on every cron for 24 hours https://issues.civicrm.org/jira/browse/CRM-17028 --- diff --git a/CRM/Core/BAO/ActionSchedule.php b/CRM/Core/BAO/ActionSchedule.php index 667f3b4d32..6c1c763973 100755 --- a/CRM/Core/BAO/ActionSchedule.php +++ b/CRM/Core/BAO/ActionSchedule.php @@ -1337,25 +1337,25 @@ GROUP BY c.id $repeatEvent = ($actionSchedule->end_action == 'before' ? 'DATE_SUB' : 'DATE_ADD') . "({$dateField}, INTERVAL {$actionSchedule->end_frequency_interval} {$actionSchedule->end_frequency_unit})"; if ($actionSchedule->repetition_frequency_unit == 'day') { - $hrs = 24 * $actionSchedule->repetition_frequency_interval; + $interval = "{$actionSchedule->repetition_frequency_interval} DAY"; } elseif ($actionSchedule->repetition_frequency_unit == 'week') { - $hrs = 24 * $actionSchedule->repetition_frequency_interval * 7; + $interval = "{$actionSchedule->repetition_frequency_interval} WEEK"; } elseif ($actionSchedule->repetition_frequency_unit == 'month') { - $hrs = "24*(DATEDIFF(DATE_ADD(latest_log_time, INTERVAL 1 MONTH ), latest_log_time))"; + $interval = "{$actionSchedule->repetition_frequency_interval} MONTH"; } elseif ($actionSchedule->repetition_frequency_unit == 'year') { - $hrs = "24*(DATEDIFF(DATE_ADD(latest_log_time, INTERVAL 1 YEAR ), latest_log_time))"; + $interval = "{$actionSchedule->repetition_frequency_interval} YEAR"; } else { - $hrs = $actionSchedule->repetition_frequency_interval; + $interval = "{$actionSchedule->repetition_frequency_interval} HOUR"; } // (now <= repeat_end_time ) $repeatEventClause = "'{$now}' <= {$repeatEvent}"; // diff(now && logged_date_time) >= repeat_interval - $havingClause = "HAVING TIMEDIFF({$now}, latest_log_time) >= TIME('{$hrs}:00:00')"; + $havingClause = "HAVING TIMESTAMPDIFF(HOUR, latest_log_time, CAST({$now} AS datetime)) >= TIMESTAMPDIFF(HOUR, latest_log_time, DATE_ADD(latest_log_time, INTERVAL $interval))"; $groupByClause = 'GROUP BY reminder.contact_id, reminder.entity_id, reminder.entity_table'; $selectClause .= ', MAX(reminder.action_date_time) as latest_log_time'; //CRM-15376 - do not send our reminders if original criteria no longer applies