CRM-14879: basics for contact fields to display in schedule reminders form
authorAndrew Hunt <andrew@aghstrategies.com>
Mon, 16 Jun 2014 15:45:53 +0000 (11:45 -0400)
committerAndrew Hunt <andrew@aghstrategies.com>
Wed, 18 Jun 2014 16:56:12 +0000 (12:56 -0400)
----------------------------------------
* CRM-14879: Scheduled reminders for contact date fields
  https://issues.civicrm.org/jira/browse/CRM-14879

CRM/Core/BAO/ActionSchedule.php

index 7102700a2587ef6e29f8dd8a99666f63bad9b85f..585c95cd509450f5e1800ae76ac83e27635f853c 100755 (executable)
@@ -88,6 +88,7 @@ class CRM_Core_BAO_ActionSchedule extends CRM_Core_DAO_ActionSchedule {
     $eventTemplate = CRM_Event_PseudoConstant::eventTemplates();
     $autoRenew = CRM_Core_OptionGroup::values('auto_renew_options');
     $membershipType = CRM_Member_PseudoConstant::membershipType();
+    $dateFields = array('birth_date' => ts('Birth Date'));
 
     asort($activityType);
 
@@ -148,6 +149,13 @@ class CRM_Core_BAO_ActionSchedule extends CRM_Core_DAO_ActionSchedule {
           }
           $sel2[$key] = $valueLabel + $membershipType;
           break;
+
+        case 'birth_date':
+          if ($value['entity'] == 'civicrm_contact') {
+            $sel1Val = ts('Contact');
+          }
+          $sel2[$key] = $valueLabel + $dateFields;
+          break;
       }
       $sel1[$key] = $sel1Val;
 
@@ -213,6 +221,16 @@ class CRM_Core_BAO_ActionSchedule extends CRM_Core_DAO_ActionSchedule {
           }
           break;
 
+        case 'none':
+          foreach ($sel3[$id] as $kkey => & $vval) {
+            $vval = $statusLabel;
+          }
+          break;
+
+        case null:
+          $sel3[$id] = array('' => 'hello there');
+          break;
+
         case '':
           $sel3[$id] = '';
           break;
@@ -717,6 +735,13 @@ LEFT JOIN civicrm_phone phone ON phone.id = lb.phone_id
         }
       }
 
+      if ($mapping->entity == 'civicrm_contact') {
+        $tokenEntity = 'contact';
+        //TODO: get full list somewhere!
+        $tokenFields = array('birth_date', 'last_name');
+        //TODO: is there anything to add here?
+      }
+
       $entityJoinClause = "INNER JOIN {$mapping->entity} e ON e.id = reminder.entity_id";
       if ($actionSchedule->limit_to == 0) {
         $entityJoinClause = "LEFT JOIN {$mapping->entity} e ON e.id = reminder.entity_id";
@@ -995,6 +1020,10 @@ WHERE reminder.action_schedule_id = %1 AND reminder.action_date_time IS NULL
         $where[] = "e.status_id IN ({$mStatus})";
       }
 
+      if ($mapping->entity == 'civicrm_contact') {
+        // TODO get this working
+      }
+
       // CRM-13577 Introduce Smart Groups Handling
       if ($actionSchedule->group_id) {
 
@@ -1332,4 +1361,3 @@ WHERE     m.owner_membership_id IS NOT NULL AND
     return $options;
   }
 }
-