CRM-13947: fix where clause condition
authoryashodha <yashodha.chaku@webaccess.co.in>
Fri, 10 Jan 2014 08:20:42 +0000 (13:50 +0530)
committeryashodha <yashodha.chaku@webaccess.co.in>
Fri, 10 Jan 2014 08:20:42 +0000 (13:50 +0530)
CRM/Core/BAO/ActionSchedule.php

index decb24753ccc6b39de118bee79d6c4270db2dd4b..5bfedcecdc220813f8de052472723fcd3281e302 100755 (executable)
@@ -1026,14 +1026,18 @@ LEFT JOIN {$reminderJoinClause}
           reminder.entity_id          = c.id AND
           reminder.entity_table       = 'civicrm_contact' AND
           reminder.action_schedule_id = {$actionSchedule->id}";
-
+        $addWhereClause = '';
+        if ($addWhere) {
+          $addWhereClause = "AND {$addWhere}";
+        }
         $insertAdditionalSql ="
 INSERT INTO civicrm_action_log (contact_id, entity_id, entity_table, action_schedule_id)
 {$addSelect}
 FROM ({$contactTable}, {$table})
 LEFT JOIN {$additionReminderClause}
 {$addGroup}
-{$additionWhere} c.is_deleted = 0 AND c.is_deceased = 0 AND {$addWhere}
+{$additionWhere} c.is_deleted = 0 AND c.is_deceased = 0
+{$addWhereClause}
 AND {$dateClause}
 AND c.id NOT IN (
      SELECT rem.contact_id