diff --git a/CRM/Admin/Form/ScheduleReminders.php b/CRM/Admin/Form/ScheduleReminders.php index fed6ba0cc8109a145a9149474b9a435f9cce9506..dbefe63ece36208d19e4e292fd649bca2b9f9d67 100644 --- a/CRM/Admin/Form/ScheduleReminders.php +++ b/CRM/Admin/Form/ScheduleReminders.php @@ -100,7 +100,7 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { $this->assign('entityMapping', json_encode($entityMapping)); $this->assign('recipientMapping', json_encode($recipientMapping)); - $sel = &$this->add( + $sel = & $this->add( 'hierselect', 'entity', ts('Entity'), @@ -175,7 +175,10 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { ); } - $this->add('select', 'recipient', ts('Limit Recipients'), $sel5[$recipient], + $limitOptions = array(1 => ts('Limit to'), 0 => ts('Addition to')); + $this->add('select', 'limit_to', ts('Limit Options'), $limitOptions); + + $this->add('select', 'recipient', ts('Recipients'), $sel5[$recipient], FALSE, array('onClick' => "showHideByValue('recipient','manual','recipientManual','table-row','select',false); showHideByValue('recipient','group','recipientGroup','table-row','select',false);") ); @@ -189,14 +192,14 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { $recipientListing->setMultiple(TRUE); $this->add('hidden', 'is_recipient_listing', empty($recipientListingOptions) ? FALSE : TRUE, array('id' => 'is_recipient_listing')); - //autocomplete url + //auto-complete url $dataUrl = CRM_Utils_System::url('civicrm/ajax/rest', 'className=CRM_Contact_Page_AJAX&fnName=getContactList&json=1&context=activity&reset=1', FALSE, NULL, FALSE ); $this->assign('dataUrl', $dataUrl); - //tokeninput url + //token input url $tokenUrl = CRM_Utils_System::url('civicrm/ajax/checkemail', 'noemail=1', FALSE, NULL, FALSE @@ -334,20 +337,24 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { 'subject', 'absolute_date', 'group_id', - 'record_activity' + 'record_activity', + 'limit_to' ); foreach ($keys as $key) { $params[$key] = CRM_Utils_Array::value($key, $values); } $moreKeys = array( - 'start_action_offset', 'start_action_unit', - 'start_action_condition', 'start_action_date', + 'start_action_offset', + 'start_action_unit', + 'start_action_condition', + 'start_action_date', 'repetition_frequency_unit', 'repetition_frequency_interval', 'end_frequency_unit', 'end_frequency_interval', - 'end_action', 'end_date', + 'end_action', + 'end_date', ); if ($absoluteDate = CRM_Utils_Array::value('absolute_date', $params)) { diff --git a/CRM/Core/BAO/ActionSchedule.php b/CRM/Core/BAO/ActionSchedule.php index 30712cec5e0903a16ecea5186ef9ba6c116bc9d5..3d68aaddaae553cf1593efcb0e32d991438d4f1d 100755 --- a/CRM/Core/BAO/ActionSchedule.php +++ b/CRM/Core/BAO/ActionSchedule.php @@ -87,8 +87,9 @@ class CRM_Core_BAO_ActionSchedule extends CRM_Core_DAO_ActionSchedule { asort($activityType); $sel1 = $sel2 = $sel3 = $sel4 = $sel5 = array(); - $options = array('manual' => ts('Choose Recipient(s)'), - 'group' => ts('Select a Group'), + $options = array( + 'manual' => ts('Choose Recipient(s)'), + 'group' => ts('Select a Group'), ); $entityMapping = array(); @@ -99,14 +100,14 @@ class CRM_Core_BAO_ActionSchedule extends CRM_Core_DAO_ActionSchedule { } foreach ($mapping as $value) { - $entityValue = CRM_Utils_Array::value('entity_value', $value); - $entityStatus = CRM_Utils_Array::value('entity_status', $value); - $entityRecipient = CRM_Utils_Array::value('entity_recipient', $value); - $valueLabel = array('- ' . strtolower(CRM_Utils_Array::value('entity_value_label', $value)) . ' -'); - $key = CRM_Utils_Array::value('id', $value); + $entityValue = CRM_Utils_Array::value('entity_value', $value); + $entityStatus = CRM_Utils_Array::value('entity_status', $value); + $entityRecipient = CRM_Utils_Array::value('entity_recipient', $value); + $valueLabel = array('- ' . strtolower(CRM_Utils_Array::value('entity_value_label', $value)) . ' -'); + $key = CRM_Utils_Array::value('id', $value); $entityMapping[$key] = CRM_Utils_Array::value('entity', $value); - $sel1Val = null; + $sel1Val = NULL; switch ($entityValue) { case 'activity_type': if ($value['entity'] == 'civicrm_activity') { @@ -176,8 +177,8 @@ class CRM_Core_BAO_ActionSchedule extends CRM_Core_DAO_ActionSchedule { foreach ($mapping as $value) { $entityStatus = CRM_Utils_Array::value('entity_status', $value); - $statusLabel = array('- ' . strtolower(CRM_Utils_Array::value('entity_status_label', $value)) . ' -'); - $id = CRM_Utils_Array::value('id', $value); + $statusLabel = array('- ' . strtolower(CRM_Utils_Array::value('entity_status_label', $value)) . ' -'); + $id = CRM_Utils_Array::value('id', $value); switch ($entityStatus) { case 'activity_status': @@ -227,9 +228,10 @@ class CRM_Core_BAO_ActionSchedule extends CRM_Core_DAO_ActionSchedule { static function getSelection1($id = NULL) { $mapping = self::getMapping($id); - $sel4 = $sel5 = array(); - $options = array('manual' => ts('Choose Recipient(s)'), - 'group' => ts('Select a Group'), + $sel4 = $sel5 = array(); + $options = array( + 'manual' => ts('Choose Recipient(s)'), + 'group' => ts('Select a Group'), ); $recipientMapping = array_combine(array_keys($options), array_keys($options)); @@ -328,8 +330,9 @@ WHERE cas.entity_value = $id AND $query .= $where; - $params = array(1 => array($id, 'Integer'), - 2 => array($entityValue, 'String'), + $params = array( + 1 => array($id, 'Integer'), + 2 => array($entityValue, 'String'), ); } @@ -639,7 +642,7 @@ WHERE reminder.action_schedule_id = %1 AND reminder.action_date_time IS NULL {$extraWhere}"; $dao = CRM_Core_DAO::executeQuery($query, - array(1 => array($actionSchedule->id, 'Integer')) + array(1 => array($actionSchedule->id, 'Integer')) ); while ($dao->fetch()) { @@ -733,14 +736,14 @@ WHERE reminder.action_schedule_id = %1 AND reminder.action_date_time IS NULL $mapping->find(TRUE); $select = $join = $where = array(); - + $limitTo = $actionSchedule->limit_to; $value = explode(CRM_Core_DAO::VALUE_SEPARATOR, - trim($actionSchedule->entity_value, CRM_Core_DAO::VALUE_SEPARATOR) + trim($actionSchedule->entity_value, CRM_Core_DAO::VALUE_SEPARATOR) ); $value = implode(',', $value); $status = explode(CRM_Core_DAO::VALUE_SEPARATOR, - trim($actionSchedule->entity_status, CRM_Core_DAO::VALUE_SEPARATOR) + trim($actionSchedule->entity_status, CRM_Core_DAO::VALUE_SEPARATOR) ); $status = implode(',', $status); @@ -758,16 +761,16 @@ WHERE reminder.action_schedule_id = %1 AND reminder.action_date_time IS NULL switch (CRM_Utils_Array::value($actionSchedule->recipient, $recipientOptions)) { case 'Activity Assignees': - $join[] = "INNER JOIN civicrm_activity_contact r ON r.activity_id = e.id AND record_type_id = {$assigneeID}"; + $join[] = "INNER JOIN civicrm_activity_contact r ON r.activity_id = e.id AND record_type_id = {$assigneeID}"; break; case 'Activity Source': - $join[] = "INNER JOIN civicrm_activity_contact r ON r.activity_id = e.id AND record_type_id = {$sourceID}"; + $join[] = "INNER JOIN civicrm_activity_contact r ON r.activity_id = e.id AND record_type_id = {$sourceID}"; break; default: case 'Activity Targets': - $join[] = "INNER JOIN civicrm_activity_contact r ON r.activity_id = e.id AND record_type_id = {$targetID}"; + $join[] = "INNER JOIN civicrm_activity_contact r ON r.activity_id = e.id AND record_type_id = {$targetID}"; break; } @@ -792,7 +795,7 @@ WHERE reminder.action_schedule_id = %1 AND reminder.action_date_time IS NULL $join[] = 'INNER JOIN civicrm_event r ON e.event_id = r.id'; if ($actionSchedule->recipient_listing) { $rList = explode(CRM_Core_DAO::VALUE_SEPARATOR, - trim($actionSchedule->recipient_listing, CRM_Core_DAO::VALUE_SEPARATOR) + trim($actionSchedule->recipient_listing, CRM_Core_DAO::VALUE_SEPARATOR) ); $rList = implode(',', $rList); @@ -863,10 +866,10 @@ WHERE reminder.action_schedule_id = %1 AND reminder.action_date_time IS NULL $where[] = "{$contactField} IN ({$rList})"; } - $select[] = "{$contactField} as contact_id"; - $select[] = 'e.id as entity_id'; - $select[] = "'{$mapping->entity}' as entity_table"; - $select[] = "{$actionSchedule->id} as action_schedule_id"; + $select[] = "{$contactField} as contact_id"; + $select[] = 'e.id as entity_id'; + $select[] = "'{$mapping->entity}' as entity_table"; + $select[] = "{$actionSchedule->id} as action_schedule_id"; $reminderJoinClause = "civicrm_action_log reminder ON reminder.contact_id = {$contactField} AND reminder.entity_id = e.id AND reminder.entity_table = '{$mapping->entity}' AND @@ -875,10 +878,10 @@ reminder.action_schedule_id = %1"; $join[] = "INNER JOIN civicrm_contact c ON c.id = {$contactField} AND c.is_deleted = 0 AND c.is_deceased = 0 "; if ($actionSchedule->start_action_date) { - $startDateClause = array(); - $op = ($actionSchedule->start_action_condition == 'before' ? '<=' : '>='); - $operator = ($actionSchedule->start_action_condition == 'before' ? 'DATE_SUB' : 'DATE_ADD'); - $date = $operator . "({$dateField}, INTERVAL {$actionSchedule->start_action_offset} {$actionSchedule->start_action_unit})"; + $startDateClause = array(); + $op = ($actionSchedule->start_action_condition == 'before' ? '<=' : '>='); + $operator = ($actionSchedule->start_action_condition == 'before' ? 'DATE_SUB' : 'DATE_ADD'); + $date = $operator . "({$dateField}, INTERVAL {$actionSchedule->start_action_offset} {$actionSchedule->start_action_unit})"; $startDateClause[] = "'{$now}' >= {$date}"; if ($mapping->entity == 'civicrm_participant') { $startDateClause[] = $operator. "({$now}, INTERVAL 1 DAY ) {$op} " . $dateField; @@ -898,9 +901,9 @@ reminder.action_schedule_id = %1"; // start composing query $selectClause = 'SELECT ' . implode(', ', $select); - $fromClause = "FROM $from"; - $joinClause = !empty($join) ? implode(' ', $join) : ''; - $whereClause = 'WHERE ' . implode(' AND ', $where); + $fromClause = "FROM $from"; + $joinClause = !empty($join) ? implode(' ', $join) : ''; + $whereClause = 'WHERE ' . implode(' AND ', $where); $query = " INSERT INTO civicrm_action_log (contact_id, entity_id, entity_table, action_schedule_id) @@ -1010,8 +1013,9 @@ WHERE m.owner_membership_id IS NOT NULL AND WHERE mapping_id = %1 AND entity_value = %2"; - $params = array(1 => array($mappingID, 'Integer'), - 2 => array($id, 'Integer'), + $params = array( + 1 => array($mappingID, 'Integer'), + 2 => array($id, 'Integer'), ); return CRM_Core_DAO::singleValueQuery($queryString, $params); } diff --git a/CRM/Event/Form/ManageEvent/ScheduleReminders.php b/CRM/Event/Form/ManageEvent/ScheduleReminders.php index 7da7e3f2519af4012b061b241439d71a0251fc6d..22ce71fbd438a4feb518a040735a50ae75c01ba2 100755 --- a/CRM/Event/Form/ManageEvent/ScheduleReminders.php +++ b/CRM/Event/Form/ManageEvent/ScheduleReminders.php @@ -116,7 +116,9 @@ class CRM_Event_Form_ManageEvent_ScheduleReminders extends CRM_Event_Form_Manage parent::buildQuickForm(); $this->add('text', 'title', ts('Reminder Name'), array( - 'size' => 45, 'maxlength' => 128), TRUE + 'size' => 45, + 'maxlength' => 128 + ), TRUE ); $selectionOptions = CRM_Core_BAO_ActionSchedule::getSelection($this->_mappingID); @@ -166,7 +168,10 @@ class CRM_Event_Form_ManageEvent_ScheduleReminders extends CRM_Event_Form_Manage $this->add('select', 'end_date', ts('Date Field'), $sel4, TRUE); $recipient = 'event_contacts'; - $this->add('select', 'recipient', ts('Limit Recipients'), $sel5[$recipient], + $limitOptions = array(1 => ts('Limit to'), 0 => ts('Addition to')); + $this->add('select', 'limit_to', ts('Limit Options'), $limitOptions); + + $this->add('select', 'recipient', ts('Recipients'), $sel5[$recipient], FALSE, array('onClick' => "showHideByValue('recipient','manual','recipientManual','table-row','select',false); showHideByValue('recipient','group','recipientGroup','table-row','select',false);") ); $recipientListing = $this->add('select', 'recipient_listing', ts('Recipient Listing'), @@ -174,14 +179,14 @@ class CRM_Event_Form_ManageEvent_ScheduleReminders extends CRM_Event_Form_Manage ); $recipientListing->setMultiple(TRUE); - //autocomplete url + //auto-complete url $dataUrl = CRM_Utils_System::url('civicrm/ajax/rest', "className=CRM_Contact_Page_AJAX&fnName=getContactList&json=1&context=activity&reset=1", FALSE, NULL, FALSE ); $this->assign('dataUrl', $dataUrl); - //tokeninput url + //token input url $tokenUrl = CRM_Utils_System::url('civicrm/ajax/checkemail', 'noemail=1', FALSE, NULL, FALSE @@ -255,20 +260,24 @@ class CRM_Event_Form_ManageEvent_ScheduleReminders extends CRM_Event_Form_Manage 'subject', 'absolute_date', 'group_id', - 'record_activity' + 'record_activity', + 'limit_to' ); foreach ($keys as $key) { $params[$key] = CRM_Utils_Array::value($key, $values); } $moreKeys = array( - 'start_action_offset', 'start_action_unit', - 'start_action_condition', 'start_action_date', + 'start_action_offset', + 'start_action_unit', + 'start_action_condition', + 'start_action_date', 'repetition_frequency_unit', 'repetition_frequency_interval', 'end_frequency_unit', 'end_frequency_interval', - 'end_action', 'end_date', + 'end_action', + 'end_date', ); if ($absoluteDate = CRM_Utils_Array::value('absolute_date', $params)) { diff --git a/templates/CRM/Admin/Form/ScheduleReminders.tpl b/templates/CRM/Admin/Form/ScheduleReminders.tpl index e9835b21221e0046411b2f2b1da7889d352a0b77..70bb68408b3a1bdc21ed64b4b330ab3579cb31a9 100644 --- a/templates/CRM/Admin/Form/ScheduleReminders.tpl +++ b/templates/CRM/Admin/Form/ScheduleReminders.tpl @@ -108,7 +108,7 @@ </td> </tr> <tr class="crm-scheduleReminder-form-block-recipient"> - <td id="recipientLabel" class="right">{$form.recipient.label}</td><td colspan="3">{$form.recipient.html} {help id="recipient" title=$form.recipient.label}</td> + <td id="recipientLabel" class="right">{$form.recipient.label}</td><td colspan="3">{$form.limit_to.html} {$form.recipient.html} {help id="recipient" title=$form.recipient.label}</td> </tr> <tr id="recipientList" class="crm-scheduleReminder-form-block-recipientListing"> <td class="right">{$form.recipient_listing.label}</td><td colspan="3">{$form.recipient_listing.html}</td> diff --git a/templates/CRM/Event/Form/ManageEvent/ScheduleReminders.tpl b/templates/CRM/Event/Form/ManageEvent/ScheduleReminders.tpl index 8e7071b270f3a8ae89fb189f9b350b22f798fcea..f043d43caac47e4255414405b1ffff4dbef6227c 100755 --- a/templates/CRM/Event/Form/ManageEvent/ScheduleReminders.tpl +++ b/templates/CRM/Event/Form/ManageEvent/ScheduleReminders.tpl @@ -122,7 +122,7 @@ </td> </tr> <tr class="crm-scheduleReminder-form-block-recipient"> - <td class="right">{$form.recipient.label}</td><td colspan="3">{$form.recipient.html} {help id="recipient" file="CRM/Admin/Page/ScheduleReminders.hlp" title=$form.recipient.label}</td> + <td class="right">{$form.recipient.label}</td><td colspan="3">{$form.limit_to.html} {$form.recipient.html} {help id="recipient" file="CRM/Admin/Page/ScheduleReminders.hlp" title=$form.recipient.label}</td> </tr> <tr id="recipientList" class="crm-scheduleReminder-form-block-recipientListing"> <td class="right">{$form.recipient_listing.label}</td><td colspan="3">{$form.recipient_listing.html}</td> diff --git a/xml/schema/Core/ActionSchedule.xml b/xml/schema/Core/ActionSchedule.xml index 1d4dff806c86cd3a60d30b40260b7d429db058b3..d1462b02cd8702216748d75431f1e30d6d17c8f8 100644 --- a/xml/schema/Core/ActionSchedule.xml +++ b/xml/schema/Core/ActionSchedule.xml @@ -39,6 +39,13 @@ <comment>Recipient</comment> <add>3.4</add> </field> + <field> + <name>limit_to</name> + <type>boolean</type> + <default>1</default> + <comment>Is this the recipient criteria limited to OR in addition to?</comment> + <add>4.4</add> + </field> <field> <name>entity_value</name> <type>varchar</type>