}
}
-
return array(
'sel1' => $sel1,
'sel2' => $sel2,
$extraJoin = "
INNER JOIN civicrm_option_group og ON og.name = 'activity_type'
INNER JOIN civicrm_option_value ov ON e.activity_type_id = ov.value AND ov.option_group_id = og.id";
- $extraOn = 'AND e.is_current_revision = 1 AND e.is_deleted = 0';
+ $extraOn = ' AND e.is_current_revision = 1 AND e.is_deleted = 0 ';
if ($actionSchedule->limit_to == 0) {
$extraJoin = "
LEFT JOIN civicrm_option_group og ON og.name = 'activity_type'
$fromClause = "FROM $from";
$joinClause = !empty($join) ? implode(' ', $join) : '';
$whereClause = 'WHERE ' . implode(' AND ', $where);
- $limitWhere .= implode(' AND ', $limitWhere);
+ $limitWhereClause = '';
+ if (!empty($limitWhere)) {
+ $limitWhereClause = ' AND ' . implode(' AND ', $limitWhere);
+ }
$query = "
INSERT INTO civicrm_action_log (contact_id, entity_id, entity_table, action_schedule_id)
{$fromClause}
{$joinClause}
LEFT JOIN {$reminderJoinClause}
-{$whereClause} {$limitWhere} AND {$dateClause} {$notINClause}
+{$whereClause} {$limitWhereClause} AND {$dateClause} {$notINClause}
";
-
CRM_Core_DAO::executeQuery($query, array(1 => array($actionSchedule->id, 'Integer')));
if ($limitTo == 0) {
reminder.entity_table = 'civicrm_contact' AND
reminder.action_schedule_id = {$actionSchedule->id}
{$addGroup}
-{$additionWhere} (reminder.id IS NULL AND c.is_deleted = 0 AND c.is_deceased = 0 AND {$addWhere})
+{$additionWhere} AND c.is_deleted = 0 AND c.is_deceased = 0 AND {$addWhere}
AND {$dateClause}
AND c.id NOT IN (
SELECT rem.contact_id
WHERE rem.action_schedule_id = {$actionSchedule->id}
AND rem.entity_table = '{$mapping->entity}'
)
+GROUP BY c.id
";
CRM_Core_DAO::executeQuery($insertAdditionalSql);
}