Ejemplo n.º 1
0
 /**
  * This method populates the civicrm_activity_history table
  */
 private function addActivity()
 {
     $contactDAO = new CRM_Contact_DAO_Contact();
     $contactDAO->contact_type = 'Individual';
     $contactDAO->selectAdd();
     $contactDAO->selectAdd('id');
     $contactDAO->orderBy('sort_name');
     $contactDAO->find();
     $count = 0;
     $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
     while ($contactDAO->fetch()) {
         if ($count++ > 2) {
             break;
         }
         for ($i = 0; $i < self::NUM_ACTIVITY; $i++) {
             $activityDAO = new CRM_Activity_DAO_Activity();
             $activityId = CRM_Core_OptionGroup::values('activity_type', NULL, NULL, NULL, ' AND v.name IN ("Tell A Friend", "Pledge Acknowledgment")');
             $activityTypeID = array_rand($activityId);
             $activity = CRM_Core_PseudoConstant::activityType();
             $activityDAO->activity_type_id = $activityTypeID;
             $activityDAO->subject = "Subject for {$activity[$activityTypeID]}";
             $activityDAO->activity_date_time = $this->randomDate();
             $activityDAO->status_id = 2;
             $this->_insert($activityDAO);
             $activityContactDAO = new CRM_Activity_DAO_ActivityContact();
             $activityContactDAO->activity_id = $activityDAO->id;
             $activityContactDAO->contact_id = $contactDAO->id;
             $activityContactDAO->record_type_id = CRM_Utils_Array::key('Activity Source', $activityContacts);
             $this->_insert($activityContactDAO);
             if ($activityTypeID == 9) {
                 $activityContactDAO = new CRM_Activity_DAO_ActivityContact();
                 $activityContactDAO->activity_id = $activityDAO->id;
                 $activityContactDAO->contact_id = mt_rand(1, 101);
                 $activityContactDAO->record_type_id = CRM_Utils_Array::key('Activity Targets', $activityContacts);
                 $this->_insert($activityContactDAO);
             }
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * This method populates the civicrm_activity_history table
  */
 private function addActivity()
 {
     $contactDAO = new CRM_Contact_DAO_Contact();
     $contactDAO->contact_type = 'Individual';
     $contactDAO->selectAdd();
     $contactDAO->selectAdd('id');
     $contactDAO->orderBy('sort_name');
     $contactDAO->find();
     $count = 0;
     $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
     while ($contactDAO->fetch()) {
         if ($count++ > 2) {
             break;
         }
         for ($i = 0; $i < self::NUM_ACTIVITY; $i++) {
             $activityDAO = new CRM_Activity_DAO_Activity();
             $activityTypeID = mt_rand(7, 10);
             $activity = CRM_Core_PseudoConstant::activityType();
             $activityDAO->activity_type_id = $activityTypeID;
             $activityDAO->subject = "Subject for {$activity[$activityTypeID]}";
             $activityDAO->activity_date_time = $this->randomDate();
             $activityDAO->duration = mt_rand(1, 6);
             $activityDAO->status_id = 2;
             $this->_insert($activityDAO);
             $activityContactDAO = new CRM_Activity_DAO_ActivityContact();
             $activityContactDAO->activity_id = $activityDAO->id;
             $activityContactDAO->contact_id = $contactDAO->id;
             $activityContactDAO->record_type_id = CRM_Utils_Array::key('Activity Source', $activityContacts);
             $this->_insert($activityContactDAO);
             if (in_array($activityTypeID, array(6, 9))) {
                 $activityContactDAO = new CRM_Activity_DAO_ActivityContact();
                 $activityContactDAO->activity_id = $activityDAO->id;
                 $activityContactDAO->contact_id = mt_rand(1, 101);
                 $activityContactDAO->record_type_id = CRM_Utils_Array::key('Activity Targets', $activityContacts);
                 $this->_insert($activityContactDAO);
             }
             if ($activityTypeID == 7) {
                 $activityContactDAO = new CRM_Activity_DAO_ActivityContact();
                 $activityContactDAO->activity_id = $activityDAO->id;
                 $activityContactDAO->contact_id = mt_rand(1, 101);
                 $activityContactDAO->record_type_id = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
                 $this->_insert($activityContactDAO);
             }
         }
     }
 }