CRM-15481 fix - Scheduled Reminders job failure with event reminders
authormonishdeb <monish.deb@webaccessglobal.com>
Tue, 21 Oct 2014 14:35:03 +0000 (20:05 +0530)
committermonishdeb <monish.deb@webaccessglobal.com>
Tue, 21 Oct 2014 14:35:03 +0000 (20:05 +0530)
https://issues.civicrm.org/jira/browse/CRM-15481

CRM/Core/BAO/ActionSchedule.php

index d48cc36f942f2fd5e26ef6aa0836c1e5d61a603d..9e8e284d257c8c0e01b062c98dd069f8af01c440 100755 (executable)
@@ -775,7 +775,7 @@ LEFT JOIN civicrm_phone phone ON phone.id = lb.phone_id
       $entityJoinClause .= $extraOn;
 
       $query = "
-SELECT reminder.id as reminderID, reminder.contact_id as contactID, reminder.*, e.id as entityID, e.* {$extraSelect}
+SELECT reminder.id as reminderID, reminder.contact_id as contactID, reminder.entity_table as entityTable, reminder.*, e.id as entityID, e.* {$extraSelect}
 FROM  civicrm_action_log reminder
 {$entityJoinClause}
 {$extraJoin}
@@ -808,9 +808,14 @@ WHERE reminder.action_schedule_id = %1 AND reminder.action_date_time IS NULL
             $entityTokenParams["{$tokenEntity}." . $field] = CRM_Utils_Date::customFormat($dao->$field);
           }
           elseif ($field == 'balance') {
-            $info = CRM_Contribute_BAO_Contribution::getPaymentInfo($dao->entityID, 'event');
-            $balancePay = CRM_Utils_Array::value('balance', $info);
-            $balancePay = CRM_Utils_Money::format($balancePay);
+            if ($dao->entityTable == 'civicrm_contact') {
+              $balancePay = 'N/A';
+            }
+            elseif (!empty($dao->entityID)) {
+              $info = CRM_Contribute_BAO_Contribution::getPaymentInfo($dao->entityID, 'event');
+              $balancePay = CRM_Utils_Array::value('balance', $info);
+              $balancePay = CRM_Utils_Money::format($balancePay);
+            }
             $entityTokenParams["{$tokenEntity}." . $field] = $balancePay;
           }
           elseif ($field == 'fee_amount') {