$this->assign('entityMapping', json_encode($entityMapping));
$this->assign('recipientMapping', json_encode($recipientMapping));
- $sel = &$this->add(
+ $sel = & $this->add(
'hierselect',
'entity',
ts('Entity'),
);
}
- $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->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
'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)) {
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();
}
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') {
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':
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));
$query .= $where;
- $params = array(1 => array($id, 'Integer'),
- 2 => array($entityValue, 'String'),
+ $params = array(
+ 1 => array($id, 'Integer'),
+ 2 => array($entityValue, 'String'),
);
}
{$extraWhere}";
$dao = CRM_Core_DAO::executeQuery($query,
- array(1 => array($actionSchedule->id, 'Integer'))
+ array(1 => array($actionSchedule->id, 'Integer'))
);
while ($dao->fetch()) {
$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);
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;
}
$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);
$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
$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;
// 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)
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);
}