Skip to content
Snippets Groups Projects
Commit 26323c36 authored by Erik Hommel's avatar Erik Hommel
Browse files

Merge branch 'master' into issue#13

parents e93c2765 5a443d46
No related branches found
No related tags found
No related merge requests found
Showing
with 222 additions and 45 deletions
......@@ -29,7 +29,12 @@ class CRM_Civirules_BAO_RuleAction extends CRM_Civirules_DAO_RuleAction {
while ($ruleAction->fetch()) {
$row = array();
self::storeValues($ruleAction, $row);
$result[$row['id']] = $row;
if (!empty($row['action_id'])) {
$result[$row['id']] = $row;
} else {
//invalid ruleAction because no there is no linked action
CRM_Civirules_BAO_RuleAction::deleteWithId($row['id']);
}
}
return $result;
}
......@@ -124,8 +129,9 @@ class CRM_Civirules_BAO_RuleAction extends CRM_Civirules_DAO_RuleAction {
public static function deleteWithRuleId($ruleId) {
$ruleAction = new CRM_Civirules_BAO_RuleAction();
$ruleAction->rule_id = $ruleId;
$ruleAction->find(false);
while ($ruleAction->fetch()) {
self::deleteWithId($ruleAction->id);
$ruleAction->delete();
}
}
......
......@@ -29,7 +29,12 @@ class CRM_Civirules_BAO_RuleCondition extends CRM_Civirules_DAO_RuleCondition {
while ($ruleCondition->fetch()) {
$row = array();
self::storeValues($ruleCondition, $row);
$result[$row['id']] = $row;
if (!empty($row['condition_id'])) {
$result[$row['id']] = $row;
} else {
//invalid ruleCondition because no there is no linked condition
CRM_Civirules_BAO_RuleCondition::deleteWithId($row['id']);
}
}
return $result;
}
......@@ -124,8 +129,9 @@ class CRM_Civirules_BAO_RuleCondition extends CRM_Civirules_DAO_RuleCondition {
public static function deleteWithRuleId($ruleId) {
$ruleCondition = new CRM_Civirules_BAO_RuleCondition();
$ruleCondition->rule_id = $ruleId;
$ruleCondition->find(FALSE);
while ($ruleCondition->fetch()) {
self::deleteWithId($ruleCondition->id);
$ruleCondition->delete();
}
}
......
......@@ -35,6 +35,13 @@ abstract class CRM_Civirules_Delay_Delay {
*/
abstract public function setValues($values);
/**
* Get the values
*
* @return array
*/
abstract public function getValues();
/**
* Returns an description of the delay
*
......
......@@ -31,4 +31,10 @@ class CRM_Civirules_Delay_XDays extends CRM_Civirules_Delay_Delay {
$this->dayOffset = $values['xdays_dayOffset'];
}
public function getValues() {
$values = array();
$values['xdays_dayOffset'] = $this->dayOffset;
return $values;
}
}
\ No newline at end of file
......@@ -31,4 +31,10 @@ class CRM_Civirules_Delay_XMinutes extends CRM_Civirules_Delay_Delay {
$this->minuteOffset = $values['xminutes_minuteOffset'];
}
public function getValues() {
$values = array();
$values['xminutes_minuteOffset'] = $this->minuteOffset;
return $values;
}
}
\ No newline at end of file
......@@ -97,6 +97,15 @@ class CRM_Civirules_Delay_XWeekDay extends CRM_Civirules_Delay_Delay {
$this->time_minute = $values['XWeekDay_time_minute'];
}
public function getValues() {
$values = array();
$values['XWeekDay_week_offset'] = $this->week_offset;
$values['XWeekDay_day'] = $this->day;
$values['XWeekDay_time_hour'] = $this->time_hour;
$values['XWeekDay_time_minute'] = $this->time_minute;
return $values;
}
/**
* Set default values
*
......
......@@ -84,6 +84,15 @@ class CRM_Civirules_Delay_XWeekDayOfMonth extends CRM_Civirules_Delay_Delay {
$this->time_minute = $values['XWeekDayOfMonth_time_minute'];
}
public function getValues() {
$values['XWeekDayOfMonth_week_offset'] = $this->week_offset;
$values['XWeekDayOfMonth_day'] = $this->day;
$values['XWeekDayOfMonth_time_hour'] = $this->time_hour;
$values['XWeekDayOfMonth_time_minute'] = $this->time_minute;
$values = array();
return $values;
}
/**
* Set default values
*
......
......@@ -99,7 +99,7 @@ class CRM_Civirules_Engine {
));
$stopTime = time() + $maxRunTime; //stop executing next item after 30 seconds
while((time() < $stopTime)) {
while((time() < $stopTime) && $queue->numberOfItems() > 0) {
$result = $runner->runNext(false);
$returnValues[] = $result;
......
......@@ -70,13 +70,11 @@ class CRM_Civirules_Form_Rule extends CRM_Core_Form {
$ruleActionAddUrl = CRM_Utils_System::url('civicrm/civirule/form/rule_action', 'reset=1&action=add&rid='.$this->ruleId, TRUE);
$this->assign('ruleConditionAddUrl', $ruleConditionAddUrl);
$this->assign('ruleActionAddUrl', $ruleActionAddUrl);
$this->assign('action', $this->_action);
$this->assign('rule', $this->rule);
$session = CRM_Core_Session::singleton();
switch($this->_action) {
case CRM_Core_Action::DELETE:
CRM_Civirules_BAO_Rule::deleteWithId($this->ruleId);
$session->setStatus('CiviRule deleted', 'Delete', 'success');
CRM_Utils_System::redirect($session->readUserContext());
break;
case CRM_Core_Action::DISABLE:
CRM_Civirules_BAO_Rule::disable($this->ruleId);
$session->setStatus('CiviRule disabled', 'Disable', 'success');
......@@ -104,9 +102,13 @@ class CRM_Civirules_Form_Rule extends CRM_Core_Form {
/*
* if add mode, set user context to form in edit mode to add conditions and actions
*/
if ($this->_action == CRM_Core_Action::ADD) {
if ($this->_action == CRM_Core_Action::ADD || $this->_action == CRM_Core_Action::UPDATE) {
$editUrl = CRM_Utils_System::url('civicrm/civirule/form/rule', 'action=update&id='.$this->ruleId, TRUE);
$session->pushUserContext($editUrl);
} elseif ($this->_action == CRM_Core_Action::DELETE) {
CRM_Civirules_BAO_Rule::deleteWithId($this->ruleId);
$session->setStatus('CiviRule deleted', 'Delete', 'success');
CRM_Utils_System::redirect($session->readUserContext());
}
if (isset($this->_submitValues['rule_event_select'])) {
......@@ -290,12 +292,10 @@ class CRM_Civirules_Form_Rule extends CRM_Core_Form {
'rule_id' => $this->ruleId);
$ruleConditions = CRM_Civirules_BAO_RuleCondition::getValues($conditionParams);
foreach ($ruleConditions as $ruleConditionId => $ruleCondition) {
$ruleConditions[$ruleConditionId]['name'] =
CRM_Civirules_BAO_Condition::getConditionLabelWithId($ruleCondition['condition_id']);
$ruleConditions[$ruleConditionId]['actions'] = $this->setRuleConditionActions($ruleConditionId);
$conditionClass = CRM_Civirules_BAO_Condition::getConditionObjectById($ruleCondition['condition_id']);
$conditionClass->setRuleConditionData($ruleCondition);
$ruleConditions[$ruleConditionId]['name'] = CRM_Civirules_BAO_Condition::getConditionLabelWithId($ruleCondition['condition_id']);
$ruleConditions[$ruleConditionId]['actions'] = $this->setRuleConditionActions($ruleConditionId, $conditionClass);
$ruleConditions[$ruleConditionId]['formattedConditionParams'] = $conditionClass->userFriendlyConditionParams();
}
return $ruleConditions;
......@@ -313,12 +313,11 @@ class CRM_Civirules_Form_Rule extends CRM_Core_Form {
'rule_id' => $this->ruleId);
$ruleActions = CRM_Civirules_BAO_RuleAction::getValues($actionParams);
foreach ($ruleActions as $ruleActionId => $ruleAction) {
$ruleActions[$ruleActionId]['label'] =
CRM_Civirules_BAO_Action::getActionLabelWithId($ruleAction['action_id']);
$ruleActions[$ruleActionId]['actions'] = $this->setRuleActionActions($ruleActionId);
$actionClass = CRM_Civirules_BAO_Action::getActionObjectById($ruleAction['action_id']);
$actionClass->setRuleActionData($ruleAction);
$ruleActions[$ruleActionId]['label'] = CRM_Civirules_BAO_Action::getActionLabelWithId($ruleAction['action_id']);
$ruleActions[$ruleActionId]['actions'] = $this->setRuleActionActions($ruleActionId, $actionClass);
$ruleActions[$ruleActionId]['formattedConditionParams'] = $actionClass->userFriendlyConditionParams();
$ruleActions[$ruleActionId]['formattedDelay'] = '';
......@@ -334,11 +333,18 @@ class CRM_Civirules_Form_Rule extends CRM_Core_Form {
* Function to set the actions for each rule condition
*
* @param int $ruleConditionId
* @param CRM_Civirules_Condition $condition
* @return array
* @access protected
*/
protected function setRuleConditionActions($ruleConditionId) {
protected function setRuleConditionActions($ruleConditionId, CRM_Civirules_Condition $condition) {
$conditionActions = array();
$editUrl = $condition->getExtraDataInputUrl($ruleConditionId);
if (!empty($editUrl)) {
$conditionActions[] = '<a class="action-item" title="Edit" href="'.$editUrl.'">'.ts('Edit').'</a>';
}
$removeUrl = CRM_Utils_System::url('civicrm/civirule/form/rule_condition', 'reset=1&action=delete&rid='
.$this->ruleId.'&id='.$ruleConditionId);
$conditionActions[] = '<a class="action-item" title="Remove" href="'.$removeUrl.'">Remove</a>';
......@@ -349,11 +355,22 @@ class CRM_Civirules_Form_Rule extends CRM_Core_Form {
* Function to set the actions for each rule action
*
* @param int $ruleActionId
* @param CRM_Civirules_Action $action
* @return array
* @access protected
*/
protected function setRuleActionActions($ruleActionId) {
protected function setRuleActionActions($ruleActionId, CRM_Civirules_Action $action) {
$actionActions = array();
$delaySettingsUrl = CRM_Utils_System::url('civicrm/civirule/form/rule_action', 'reset=1&action=update&rid='
.$this->ruleId.'&id='.$ruleActionId);
$actionActions[] = '<a class="action-item" title="Edit delay settings" href="'.$delaySettingsUrl.'">'.ts('Edit delay').'</a>';
$editUrl = $action->getExtraDataInputUrl($ruleActionId);
if (!empty($editUrl)) {
$actionActions[] = '<a class="action-item" title="Edit" href="'.$editUrl.'">'.ts('Edit').'</a>';
}
$removeUrl = CRM_Utils_System::url('civicrm/civirule/form/rule_action', 'reset=1&action=delete&rid='
.$this->ruleId.'&id='.$ruleActionId);
$actionActions[] = '<a class="action-item" title="Remove" href="'.$removeUrl.'">Remove</a>';
......@@ -380,7 +397,7 @@ class CRM_Civirules_Form_Rule extends CRM_Core_Form {
}
$ruleParams['label'] = $formValues['rule_label'];
$ruleParams['name'] = CRM_Civirules_Utils::buildNameFromLabel($formValues['rule_label']);
$ruleParams['is_active'] = $formValues['rule_is_active'];
$ruleParams['is_active'] = $formValues['rule_is_active'] ? 1 : 0;
$savedRule = CRM_Civirules_BAO_Rule::add($ruleParams);
$this->ruleId = $savedRule['id'];
}
......
......@@ -13,6 +13,12 @@ class CRM_Civirules_Form_RuleAction extends CRM_Core_Form {
protected $ruleId = NULL;
protected $ruleActionId;
protected $ruleAction;
protected $action;
/**
* Function to buildQuickForm (extends parent function)
*
......@@ -31,6 +37,24 @@ class CRM_Civirules_Form_RuleAction extends CRM_Core_Form {
*/
function preProcess() {
$this->ruleId = CRM_Utils_Request::retrieve('rid', 'Integer');
$this->ruleActionId = CRM_Utils_Request::retrieve('id', 'Integer');
if ($this->ruleActionId) {
$this->ruleAction = new CRM_Civirules_BAO_RuleAction();
$this->ruleAction->id = $this->ruleActionId;
if (!$this->ruleAction->find(true)) {
throw new Exception('Civirules could not find ruleAction');
}
$this->action = new CRM_Civirules_BAO_Action();
$this->action->id = $this->ruleAction->action_id;
if (!$this->action->find(true)) {
throw new Exception('Civirules could not find action');
}
$this->assign('action_label', $this->action->label);
}
$redirectUrl = CRM_Utils_System::url('civicrm/civirule/form/rule', 'action=update&id='.$this->ruleId, TRUE);
$session = CRM_Core_Session::singleton();
$session->pushUserContext($redirectUrl);
......@@ -53,6 +77,9 @@ class CRM_Civirules_Form_RuleAction extends CRM_Core_Form {
'action_id' => $this->_submitValues['rule_action_select'],
'delay' => 'null',
);
if ($this->ruleActionId) {
$saveParams['id'] = $this->ruleActionId;
}
if (!empty($this->_submitValues['delay_select'])) {
$delayClass = CRM_Civirules_Delay_Factory::getDelayClassByName($this->_submitValues['delay_select']);
......@@ -68,8 +95,10 @@ class CRM_Civirules_Form_RuleAction extends CRM_Core_Form {
$action = CRM_Civirules_BAO_Action::getActionObjectById($ruleAction['action_id'], true);
$redirectUrl = $action->getExtraDataInputUrl($ruleAction['id']);
if (empty($redirectUrl)) {
if (empty($redirectUrl) || $this->ruleActionId) {
$redirectUrl = CRM_Utils_System::url('civicrm/civirule/form/rule', 'action=update&id=' . $this->_submitValues['rule_id'], TRUE);
} elseif (!$this->ruleActionId) {
$redirectUrl .= '&action=add';
}
CRM_Utils_System::redirect($redirectUrl);
......@@ -82,9 +111,16 @@ class CRM_Civirules_Form_RuleAction extends CRM_Core_Form {
*/
protected function createFormElements() {
$this->add('hidden', 'rule_id');
if ($this->ruleActionId) {
$this->add('hidden', 'id');
}
$actionList = array(' - select - ') + CRM_Civirules_Utils::buildActionList();
asort($actionList);
$this->add('select', 'rule_action_select', ts('Select Action'), $actionList);
$attributes = array();
if (empty($this->ruleActionId)) {
$this->add('select', 'rule_action_select', ts('Select Action'), $actionList, $attributes);
}
$delayList = array(' - No Delay - ') + CRM_Civirules_Delay_Factory::getOptionList();
$this->add('select', 'delay_select', ts('Delay action to'), $delayList);
......@@ -105,6 +141,20 @@ class CRM_Civirules_Form_RuleAction extends CRM_Core_Form {
$delay_class->setDefaultValues($defaults);
}
if (!empty($this->ruleActionId)) {
$defaults['rule_action_select'] = $this->ruleActionId;
$defaults['id'] = $this->ruleActionId;
$delayClass = unserialize($this->ruleAction->delay);
if ($delayClass) {
$defaults['delay_select'] = get_class($delayClass);
foreach($delayClass->getValues() as $key => $val) {
$defaults[$key] = $val;
}
}
}
return $defaults;
}
......@@ -125,7 +175,12 @@ class CRM_Civirules_Form_RuleAction extends CRM_Core_Form {
* @access public
*/
public function addRules() {
$this->addFormRule(array('CRM_Civirules_Form_RuleAction', 'validateRuleAction'));
if (empty($this->ruleActionId)) {
$this->addFormRule(array(
'CRM_Civirules_Form_RuleAction',
'validateRuleAction'
));
}
}
/**
......
......@@ -62,6 +62,8 @@ class CRM_Civirules_Form_RuleCondition extends CRM_Core_Form {
$redirectUrl = $condition->getExtraDataInputUrl($ruleCondition['id']);
if (empty($redirectUrl)) {
$redirectUrl = CRM_Utils_System::url('civicrm/civirule/form/rule', 'action=update&id=' . $this->_submitValues['rule_id'], TRUE);
} else {
$redirectUrl .= '&action=add';
}
$session->setStatus('Condition added to CiviRule '.CRM_Civirules_BAO_Rule::getRuleLabelWithId($this->_submitValues['rule_id']),
......
......@@ -50,19 +50,19 @@ class CRM_Civirules_Page_Rule extends CRM_Core_Page {
$rowActions = array();
$updateUrl = CRM_Utils_System::url('civicrm/civirule/form/rule', 'reset=1&action=update&id='.
$rule['id']);
//$deleteUrl = CRM_Utils_System::url('civicrm/civirule/form/rule', 'reset=1&action=delete&id='.
//$rule['id']);
$deleteUrl = CRM_Utils_System::url('civicrm/civirule/form/rule', 'reset=1&action=delete&id='.
$rule['id']);
$disableUrl = CRM_Utils_System::url('civicrm/civirule/form/rule', 'reset=1&action=disable&id='.
$rule['id']);
$enableUrl = CRM_Utils_System::url('civicrm/civirule/form/rule', 'reset=1&action=enable&id='.
$rule['id']);
$rowActions[] = '<a class="action-item" title="Update" href="'.$updateUrl.'">Edit</a>';
//$rowActions[] = '<a class="action-item" title="Delete" href="'.$deleteUrl.'">Delete</a>';
$rowActions[] = '<a class="action-item" title="Update" href="'.$updateUrl.'">'.ts('Edit').'</a>';
if ($rule['is_active'] == 1) {
$rowActions[] = '<a class="action-item" title="Disable" href="'.$disableUrl.'">Disable</a>';
$rowActions[] = '<a class="action-item" title="Disable" href="'.$disableUrl.'">'.ts('Disable').'</a>';
} else {
$rowActions[] = '<a class="action-item" title="Enable" href="'.$enableUrl.'">Enable</a>';
$rowActions[] = '<a class="action-item" title="Enable" href="'.$enableUrl.'">'.ts('Enable').'</a>';
}
$rowActions[] = '<a class="action-item" title="Delete" href="'.$deleteUrl.'">'.ts('Delete').'</a>';
return $rowActions;
}
......
......@@ -16,6 +16,7 @@ class CRM_Civirules_Utils_ObjectName {
case 'Individual':
case 'Household':
case 'Organization':
case 'Profile':
$entity = 'contact';
break;
}
......
......@@ -56,11 +56,22 @@ class CRM_CivirulesActions_Form_Form extends CRM_Core_Form
$this->eventClass = CRM_Civirules_BAO_Event::getPostEventObjectByClassName($this->event->class_name, true);
$this->eventClass->setEventId($this->event->id);
//set user context
$session = CRM_Core_Session::singleton();
$editUrl = CRM_Utils_System::url('civicrm/civirule/form/rule', 'action=update&id='.$this->rule->id, TRUE);
$session->pushUserContext($editUrl);
parent::preProcess();
$this->setFormTitle();
}
function cancelAction() {
if (isset($this->_submitValues['rule_action_id']) && $this->_action == CRM_Core_Action::ADD) {
CRM_Civirules_BAO_RuleAction::deleteWithId($this->_submitValues['rule_action_id']);
}
}
/**
* Overridden parent method to set default values
*
......
......@@ -38,7 +38,7 @@ class CRM_CivirulesConditions_Contribution_DistinctContributingDay extends CRM_C
public function isConditionValid(CRM_Civirules_EventData_EventData $eventData)
{
$isConditionValid = FALSE;
$contribution = $eventData->getEntityData('Contribution');
$contact_id = $eventData->getContactId();
/*
* retrieve count of contributions for donor grouped by extracted YMD from receive_date
*/
......@@ -46,8 +46,18 @@ class CRM_CivirulesConditions_Contribution_DistinctContributingDay extends CRM_C
EXTRACT(MONTH FROM receive_date), EXTRACT(DAY FROM receive_date))) AS distinctDates
FROM civicrm_contribution WHERE contact_id = %1 AND civicrm_contribution.contribution_status_id = %2';
$params = array(
1 => array($contribution['contact_id'], 'Positive'),
1 => array($contact_id, 'Positive'),
2 => array(CRM_Civirules_Utils::getContributionStatusIdWithName('Completed'), 'Positive'));
$periodStartDate = CRM_CivirulesConditions_Utils_Period::convertPeriodToStartDate($this->conditionParams['period']);
$periodEndDate = CRM_CivirulesConditions_Utils_Period::convertPeriodToEndDate($this->conditionParams['period']);
if ($periodStartDate) {
$query .= " AND DATE(`receive_date`) >= '".$periodStartDate->format('Y-m-d')."'";
}
if ($periodEndDate) {
$query .= " AND DATE(`receive_date`) <= '".$periodEndDate->format('Y-m-d')."'";
}
$dao = CRM_Core_DAO::executeQuery($query, $params);
if ($dao->fetch()) {
......@@ -130,16 +140,14 @@ FROM civicrm_contribution WHERE contact_id = %1 AND civicrm_contribution.contrib
$operator = 'is equal to';
break;
}
return 'Distinct number of contributing days '.$operator.' '.$this->conditionParams['no_of_days'];
}
/**
* Returns an array with required entity names
*
* @return array
* @access public
*/
public function requiredEntities() {
return array('Contribution');
$periods = CRM_CivirulesConditions_Utils_Period::Options();
if (isset($periods[$this->conditionParams['period']])) {
$period = ts('in the ').$periods[$this->conditionParams['period']];
} else {
$period = ts('all time');
}
return 'Distinct number of contributing days '.$operator.' '.$this->conditionParams['no_of_days'].' '.$period;
}
}
\ No newline at end of file
......@@ -28,7 +28,7 @@ class CRM_CivirulesConditions_Contribution_TotalContributedAmount extends CRM_Ci
if ($periodEndDate) {
$sql .= " AND DATE(`receive_date`) <= '".$periodEndDate->format('Y-m-d')."'";
}
$total_amount = (float) CRM_Core_DAO::singleValueQuery($sql, $params);
return $total_amount;
}
......
......@@ -27,6 +27,8 @@ class CRM_CivirulesConditions_Form_Contribution_DistinctContributingDay extends
$this->addRule('no_of_days','Number of Days must be a whole number','numeric');
$this->addRule('no_of_days','Number of Days must be a whole number','nopunctuation');
$this->add('select', 'period', ts('Period'), array('' => ts('All time')) + CRM_CivirulesConditions_Utils_Period::Options());
$this->addButtons(array(
array('type' => 'next', 'name' => ts('Save'), 'isDefault' => TRUE,),
array('type' => 'cancel', 'name' => ts('Cancel'))));
......@@ -47,6 +49,10 @@ class CRM_CivirulesConditions_Form_Contribution_DistinctContributingDay extends
if (!empty($data['no_of_days'])) {
$defaultValues['no_of_days'] = $data['no_of_days'];
}
if (!empty($data['period'])) {
$defaultValues['period'] = $data['period'];
}
return $defaultValues;
}
......@@ -59,6 +65,7 @@ class CRM_CivirulesConditions_Form_Contribution_DistinctContributingDay extends
public function postProcess() {
$data['operator'] = $this->_submitValues['operator'];
$data['no_of_days'] = $this->_submitValues['no_of_days'];
$data['period'] = $this->_submitValues['period'];
$this->ruleCondition->condition_params = serialize($data);
$this->ruleCondition->save();
......
......@@ -10,7 +10,7 @@ class CRM_CivirulesConditions_Form_Contribution_TotalContributedAmount extends C
public function buildQuickForm() {
parent::buildQuickForm();
$this->add('select', 'period', ts('Period'), array('' => ts('No period')) + CRM_CivirulesConditions_Utils_Period::Options());
$this->add('select', 'period', ts('Period'), array('' => ts('All time')) + CRM_CivirulesConditions_Utils_Period::Options());
}
/**
......
......@@ -72,6 +72,17 @@ class CRM_CivirulesConditions_Form_Form extends CRM_Core_Form
parent::preProcess();
$this->setFormTitle();
//set user context
$session = CRM_Core_Session::singleton();
$editUrl = CRM_Utils_System::url('civicrm/civirule/form/rule', 'action=update&id='.$this->rule->id, TRUE);
$session->pushUserContext($editUrl);
}
function cancelAction() {
if (isset($this->_submitValues['rule_condition_id']) && $this->_action == CRM_Core_Action::ADD) {
CRM_Civirules_BAO_RuleCondition::deleteWithId($this->_submitValues['rule_condition_id']);
}
}
/**
......
......@@ -13,6 +13,8 @@ class CRM_CivirulesConditions_Utils_Period {
'this month' => ts('This month'),
'previous month' => ts('Previous month'),
'last 30 days' => ts('Last 30 days'),
'last 12 months' => ts('Last 12 months'),
'last 13 months' => ts('Last 13 months'),
'this year' => ts('This year'),
'previous year' => ts('Previous year'),
);
......@@ -33,6 +35,14 @@ class CRM_CivirulesConditions_Utils_Period {
$date->modify('-30 days');
return $date;
break;
case 'last 12 months':
$date->modify('12 months');
return $date;
break;
case 'last 13 months':
$date->modify('13 months');
return $date;
break;
case 'this year':
$date->modify('first day of January this year');
return $date;
......@@ -60,6 +70,12 @@ class CRM_CivirulesConditions_Utils_Period {
case 'last 30 days':
return $date;
break;
case 'last 12 months':
return $date;
break;
case 'last 13 months':
return $date;
break;
case 'this year':
$date->modify('last day of December this year');
return $date;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment