From: BrianDombrowski Date: Wed, 13 May 2015 15:41:13 +0000 (-0400) Subject: CRM-16500 - Added more options to job frequency to make it more useable X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=7fce7b7f67e2ff18d66096f761f772f4e20c19c1;p=civicrm-core.git CRM-16500 - Added more options to job frequency to make it more useable ---------------------------------------- * CRM-16500: Add more common options to scheduled job frequency https://issues.civicrm.org/jira/browse/CRM-16500 --- diff --git a/CRM/Core/ScheduledJob.php b/CRM/Core/ScheduledJob.php index 23038e48a6..434b8613e9 100644 --- a/CRM/Core/ScheduledJob.php +++ b/CRM/Core/ScheduledJob.php @@ -107,6 +107,36 @@ class CRM_Core_ScheduledJob { case 'Daily': $format = 'Ymd'; break; + + case 'Mondays': + $now = CRM_Utils_Date::currentDBDate(); + $dayAgo = strtotime('-1 day', strtotime($now)); + $lastRun = strtotime($this->last_run); + $nowDayOfWeek = date('l',strtotime($now)); + if ($lastRun < $dayAgo and $nowDayOfWeek=='Monday') { + return TRUE; + } + + case '1stOfMth': + $now = CRM_Utils_Date::currentDBDate(); + $dayAgo = strtotime('-1 day', strtotime($now)); + $lastRun = strtotime($this->last_run); + $nowDayOfMonth = date('j',strtotime($now)); + if ($lastRun < $dayAgo and $nowDayOfMonth=='1') { + return TRUE; + } + + case '1stOfQtr': + $now = CRM_Utils_Date::currentDBDate(); + $dayAgo = strtotime('-1 day', strtotime($now)); + $lastRun = strtotime($this->last_run); + $nowDayOfMonth = date('j',strtotime($now)); + $nowMonth = date('n',strtotime($now)); + $qtrMonths = array('1','4','7','10'); + if ($lastRun < $dayAgo and $nowDayOfMonth=='13' and in_array($nowMonth,$qtrMonths)) { + return TRUE; + } + } $now = CRM_Utils_Date::currentDBDate(); diff --git a/CRM/Core/SelectValues.php b/CRM/Core/SelectValues.php index 0f77050577..6c2a9fb538 100644 --- a/CRM/Core/SelectValues.php +++ b/CRM/Core/SelectValues.php @@ -873,6 +873,9 @@ class CRM_Core_SelectValues { */ public static function getJobFrequency() { return array( + '1stOfQtr' => ts('1st day of every quarter'), + '1stOfMth' => ts('1st day of every month'), + 'Mondays' => ts('Monday of every week'), 'Daily' => ts('Daily'), 'Hourly' => ts('Hourly'), 'Always' => ts('Every time cron job is run'),