);
}
- $limitOptions = array(1 => ts('Limit to'), 0 => ts('Also include'));
- $this->add('select', 'limit_to', ts('Limit Options'), $limitOptions);
+ $limitOptions = array('' => '-neither-', 1 => ts('Limit to'), 0 => ts('Also include'));
- $this->add('select', 'recipient', ts('Recipients'), $sel5[$recipient],
+ $recipientLabels = array('activity' => ts('Recipients'), 'other' => ts('Limit or Add Recipients'));
+ $this->assign('recipientLabels', $recipientLabels);
+
+ $this->add('select', 'limit_to', ts('Limit Options'), $limitOptions, FALSE, array('onChange' => "showHideByValue('limit_to','','recipient', 'select','select',true);"));
+
+ $this->add('select', 'recipient', $recipientLabels['other'], $sel5[$recipient],
FALSE, array('onchange' => "showHideByValue('recipient','manual','recipientManual','table-row','select',false); showHideByValue('recipient','group','recipientGroup','table-row','select',false);")
);
}
}
+ $recipientKind = array(
+ 'participant_role' => array(
+ 'name' => 'participant role',
+ 'target_id' => 'recipient_listing'
+ ),
+ 'manual' => array(
+ 'name' => 'recipient',
+ 'target_id' => 'recipient_manual_id'
+ )
+ );
+ if (!empty($fields['limit_to']) && array_key_exists($fields['recipient'], $recipientKind)) {
+ $errors[$recipientKind[$fields['recipient']]['target_id']] = ts('If "Also include" or "Limit to" are selected, you must specify atleast one %1', array(1 => $recipientKind[$fields['recipient']]['name']));
+ }
+
if (!empty($errors)) {
return $errors;
}
$entity_value = $values['entity'][1];
$entity_status = $values['entity'][2];
+ if ($entity_value == 1) {
+ $params['limit_to'] = 1;
+ }
+
foreach (array(
'entity_value', 'entity_status') as $key) {
$params[$key] = implode(CRM_Core_DAO::VALUE_SEPARATOR, $$key);
CRM_Core_Session::setStatus($status, ts('Saved'), 'success');
}
}
-
break;
case 'event_contacts':
- $eventContacts = CRM_Core_OptionGroup::values('event_contacts');
+ $eventContacts = CRM_Core_OptionGroup::values('event_contacts', FALSE, FALSE, FALSE, NULL, 'label', TRUE, FALSE, 'name');
$sel5[$entityRecipient] = $eventContacts + $options;
- $recipientMapping += CRM_Core_OptionGroup::values('event_contacts', FALSE, FALSE, FALSE, NULL, 'name');
+ $recipientMapping += CRM_Core_OptionGroup::values('event_contacts', FALSE, FALSE, FALSE, NULL, 'name', TRUE, FALSE, 'name');
break;
case NULL:
break;
case 'event_contacts':
- $eventContacts = CRM_Core_OptionGroup::values('event_contacts');
+ $eventContacts = CRM_Core_OptionGroup::values('event_contacts', FALSE, FALSE, FALSE, NULL, 'label', TRUE, FALSE, 'name');
$sel5[$id] = $eventContacts + $options;
- $recipientMapping += CRM_Core_OptionGroup::values('event_contacts', FALSE, FALSE, FALSE, NULL, 'name');
+ $recipientMapping += CRM_Core_OptionGroup::values('event_contacts', FALSE, FALSE, FALSE, NULL, 'name', TRUE, FALSE, 'name');
break;
case NULL:
$assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
- if ($limitTo == 0) {
- // including the activity target contacts if 'in addition' is defined
- $join[] = "INNER JOIN civicrm_activity_contact r ON r.activity_id = e.id AND record_type_id = {$targetID}";
- }
- else {
- 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}";
- break;
-
- case 'Activity Source':
- $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}";
- break;
+ if (!empty($limitTo)) {
+ if ($limitTo == 0) {
+ // including the activity target contacts if 'in addition' is defined
+ $join[] = "INNER JOIN civicrm_activity_contact r ON r.activity_id = e.id AND record_type_id = {$targetID}";
+ }
+ else {
+ 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}";
+ break;
+
+ case 'Activity Source':
+ $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}";
+ break;
+ }
}
}
// build where clause
$where[] = "{$contactField} IN ({$rList})";
}
}
- else {
+ elseif (!empty($limitTo)) {
$addGroup = $addWhere = '';
if ($actionSchedule->group_id) {
// CRM-13577 If smart group then use Cache table
";
CRM_Core_DAO::executeQuery($query, array(1 => array($actionSchedule->id, 'Integer')));
- if ($limitTo == 0 && (!empty($addGroup) || !empty($addWhere))) {
+ if (!empty($limitTo) && $limitTo == 0 && (!empty($addGroup) || !empty($addWhere))) {
$additionWhere = ' WHERE ';
if ($actionSchedule->start_action_date) {
$additionWhere = $whereClause . ' AND ';
CRM_Core_DAO::executeQuery($query, array(1 => array($actionSchedule->id, 'Integer')));
}
- if ($limitTo == 0) {
+ if (!empty($limitTo) && $limitTo == 0) {
$addSelect .= ', MAX(reminder.action_date_time) as latest_log_time';
$sqlEndEventCheck = "
SELECT * FROM {$table}
--CRM-15361: Allow selection of location type when sending bulk email
ALTER TABLE civicrm_mailing ADD COLUMN location_type_id INT(10) unsigned DEFAULT 0 COMMENT 'With email_selection_method, determines which email address to use';
ALTER TABLE civicrm_mailing ADD COLUMN email_selection_method varchar(20) DEFAULT 'automatic' COMMENT 'With location_type_id, determine how to choose the email address to use.';
+
+-- CRM-15500 fix
+ALTER TABLE `civicrm_action_schedule` CHANGE `limit_to` `limit_to` TINYINT( 4 ) NULL DEFAULT NULL;
\ No newline at end of file
<tr class="crm-scheduleReminder-form-block-recipient">
<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">
+ <tr id="recipientList" class="crm-scheduleReminder-form-block-recipientListing recipient">
<td class="right">{$form.recipient_listing.label}</td><td colspan="3">{$form.recipient_listing.html}</td>
</tr>
- <tr id="recipientManual" class="crm-scheduleReminder-form-block-recipient_manual_id">
+ <tr id="recipientManual" class="crm-scheduleReminder-form-block-recipient_manual_id recipient">
<td class="label">{$form.recipient_manual_id.label}</td>
<td>{$form.recipient_manual_id.html}{edit}<div class="description">{ts}You can manually send out the reminders to these recipients.{/ts}</div>{/edit}</td>
</tr>
- <tr id="recipientGroup" class="crm-scheduleReminder-form-block-recipient_group_id">
+ <tr id="recipientGroup" class="crm-scheduleReminder-form-block-recipient_group_id recipient">
<td class="label">{$form.group_id.label}</td>
<td>{$form.group_id.html}</td>
</tr>
$('#mode', $form).change(loadMsgBox);
showHideLimitTo();
+ buildSelects();
$('#recipient', $form).change(populateRecipient);
+ $('#limit_to', $form).change(populateRecipient).change(buildSelects);
var entity = $('#entity_0', $form).val();
if (!(entity === '2' || entity === '3') || $('#recipient', $form).val() !== '1') {
$('#recipientList', $form).hide();
}
+ else if (entity === '1') {
+ $('#recipient', $form).change(buildSelects);
+ }
function buildSelects() {
var mappingID = $('#entity_0', $form).val();
}
function populateRecipient() {
var recipient = $("#recipient", $form).val();
-
- if (recipientMapping[recipient] == 'Participant Status' || recipientMapping[recipient] == 'participant_role') {
+ if ((recipientMapping[recipient] == 'Participant Status' || recipientMapping[recipient] == 'participant_role') && $('#limit_to').val() != '') {
CRM.api3('participant', 'getoptions', {field: recipientMapping[recipient] == 'participant_role' ? 'role_id' : 'status_id', sequential: 1})
.done(function(result) {
CRM.utils.setOptions($('#recipient_listing', $form), result.values);
} else {
$("#recipientList", $form).hide();
$('#is_recipient_listing', $form).val('');
+ if ($('#entity_0', $form).val() !== '1' && $('#limit_to').val() == '') {
+ $('tr.recipient:visible').hide();
+ }
}
}
// CRM-14070 Hide limit-to when entity is activity
function showHideLimitTo() {
$('#limit_to', $form).toggle(!($('#entity_0', $form).val() == '1'));
+ if ($('#entity_0', $form).val() != '1') {
+ if ($('#limit_to', $form).val() == '') {
+ $('#recipient').hide();
+ }
+ $("label[for='recipient']").text('{/literal}{$recipientLabels.other}{literal}');
+ }
+ else {
+ $("label[for='recipient']").text('{/literal}{$recipientLabels.activity}{literal}');
+ }
}
});
$this->fixtures['sched_activity_1day'] = array( // create()
'name' => 'One_Day_Phone_Call_Notice',
'title' => 'One Day Phone Call Notice',
+ 'limit_to' => '1',
'absolute_date' => NULL,
'body_html' => '<p>1-Day (non-repeating)</p>',
'body_text' => '1-Day (non-repeating)',
$this->fixtures['sched_activity_1day_r'] = array(
'name' => 'One_Day_Phone_Call_Notice_R',
'title' => 'One Day Phone Call Notice R',
+ 'limit_to' => 1,
'absolute_date' => NULL,
'body_html' => '<p>1-Day (repeating)</p>',
'body_text' => '1-Day (repeating)',
<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>