Exemplo n.º 1
0
 private function addParticipant()
 {
     $contact = new CRM_Contact_DAO_Contact();
     $contact->query("SELECT id FROM civicrm_contact");
     while ($contact->fetch()) {
         $contacts[] = $contact->id;
     }
     shuffle($contacts);
     $randomContacts = array_slice($contacts, 20, 50);
     $participant = "\nINSERT INTO civicrm_participant\n        (contact_id, event_id, status_id, role_id, register_date, source, fee_level, is_test, fee_amount, fee_currency)\nVALUES\n        ( " . $randomContacts[0] . ", 1, 1, 1, '2009-01-21', 'Check', 'Single', 0, 50, 'USD'),\n        ( " . $randomContacts[1] . ", 2, 2, 2, '2008-05-07', 'Credit Card', 'Soprano', 0, 50, 'USD'),\n        ( " . $randomContacts[2] . ", 3, 3, 3, '2008-05-05', 'Credit Card', 'Tiny-tots (ages 5-8)', 0, 800, 'USD') ,\n        ( " . $randomContacts[3] . ", 1, 4, 4, '2008-10-21', 'Direct Transfer', 'Single', 0, 50, 'USD'),\n        ( " . $randomContacts[4] . ", 2, 1, 1, '2008-01-10', 'Check', 'Soprano', 0, 50, 'USD'),\n        ( " . $randomContacts[5] . ", 3, 2, 2, '2008-03-05', 'Direct Transfer', 'Tiny-tots (ages 5-8)', 0, 800, 'USD'),\n        ( " . $randomContacts[6] . ", 1, 3, 3, '2009-07-21', 'Direct Transfer', 'Single', 0, 50, 'USD'),\n        ( " . $randomContacts[7] . ", 2, 4, 4, '2009-03-07', 'Credit Card', 'Soprano', 0, 50, 'USD'),\n        ( " . $randomContacts[8] . ", 3, 1, 1, '2008-02-05', 'Direct Transfer', 'Tiny-tots (ages 5-8)', 0, 800, 'USD'),\n        ( " . $randomContacts[9] . ", 1, 2, 2, '2008-02-01', 'Check', 'Single', 0, 50, 'USD'),\n        ( " . $randomContacts[10] . ", 2, 3, 3, '2009-01-10', 'Direct Transfer', 'Soprano', 0, 50, 'USD'),\n        ( " . $randomContacts[11] . ", 3, 4, 4, '2009-03-06', 'Credit Card', 'Tiny-tots (ages 5-8)', 0, 800, 'USD'),\n        ( " . $randomContacts[12] . ", 1, 1, 2, '2008-06-04', 'Credit Card', 'Single', 0, 50, 'USD'),\n        ( " . $randomContacts[13] . ", 2, 2, 3, '2008-01-10', 'Direct Transfer', 'Soprano', 0, 50, 'USD'),\n        ( " . $randomContacts[14] . ", 3, 4, 1, '2008-07-04', 'Check', 'Tiny-tots (ages 5-8)', 0, 800, 'USD'),\n        ( " . $randomContacts[15] . ", 1, 4, 2, '2009-01-21', 'Credit Card', 'Single', 0, 50, 'USD'),\n        ( " . $randomContacts[16] . ", 2, 2, 3, '2008-01-10', 'Credit Card', 'Soprano', 0, 50, 'USD'),\n        ( " . $randomContacts[17] . ", 3, 3, 1, '2009-03-05', 'Credit Card', 'Tiny-tots (ages 5-8)', 0, 800, 'USD'),\n        ( " . $randomContacts[18] . ", 1, 2, 1, '2008-10-21', 'Direct Transfer', 'Single', 0, 50, 'USD'),\n        ( " . $randomContacts[19] . ", 2, 4, 1, '2009-01-10', 'Credit Card', 'Soprano', 0, 50, 'USD'),\n        ( " . $randomContacts[20] . ", 3, 1, 4, '2008-03-25', 'Check', 'Tiny-tots (ages 5-8)', 0, 800, 'USD'),\n        ( " . $randomContacts[21] . ", 1, 2, 3, '2009-10-21', 'Direct Transfer', 'Single', 0, 50, 'USD'),\n        ( " . $randomContacts[22] . ", 2, 4, 1, '2008-01-10', 'Direct Transfer', 'Soprano', 0, 50, 'USD'),\n        ( " . $randomContacts[23] . ", 3, 3, 1, '2008-03-11', 'Credit Card', 'Tiny-tots (ages 5-8)', 0, 800, 'USD'),\n        ( " . $randomContacts[24] . ", 3, 2, 2, '2008-04-05', 'Direct Transfer', 'Tiny-tots (ages 5-8)', 0, 800, 'USD'),\n        ( " . $randomContacts[25] . ", 1, 1, 1, '2009-01-21', 'Check', 'Single', 0, 50, 'USD'),\n        ( " . $randomContacts[26] . ", 2, 2, 2, '2008-05-07', 'Credit Card', 'Soprano', 0, 50, 'USD'),\n        ( " . $randomContacts[27] . ", 3, 3, 3, '2009-12-12', 'Direct Transfer', 'Tiny-tots (ages 5-8)', 0, 800, 'USD'),\n        ( " . $randomContacts[28] . ", 1, 4, 4, '2009-12-13', 'Credit Card', 'Single', 0, 50, 'USD'),\n        ( " . $randomContacts[29] . ", 2, 1, 1, '2009-12-14', 'Direct Transfer', 'Soprano', 0, 50, 'USD'),\n        ( " . $randomContacts[30] . ", 3, 2, 2, '2009-12-15', 'Credit Card', 'Tiny-tots (ages 5-8)', 0, 800, 'USD'),\n        ( " . $randomContacts[31] . ", 1, 3, 3, '2009-07-21', 'Check', 'Single', 0, 50, 'USD'),\n        ( " . $randomContacts[32] . ", 2, 4, 4, '2009-03-07', 'Direct Transfer', 'Soprano', 0, 50, 'USD'),\n        ( " . $randomContacts[33] . ", 3, 1, 1, '2009-12-15', 'Credit Card', 'Tiny-tots (ages 5-8)', 0, 800, 'USD'),\n        ( " . $randomContacts[34] . ", 1, 2, 2, '2009-12-13', 'Direct Transfer', 'Single', 0, 50, 'USD'),\n        ( " . $randomContacts[35] . ", 2, 3, 3, '2009-01-10', 'Direct Transfer', 'Soprano', 0, 50, 'USD'),\n        ( " . $randomContacts[36] . ", 3, 4, 4, '2009-03-06', 'Check', 'Tiny-tots (ages 5-8)', 0, 800, 'USD'),\n        ( " . $randomContacts[37] . ", 1, 1, 2, '2009-12-13', 'Direct Transfer', 'Single', 0, 50, 'USD'),\n        ( " . $randomContacts[38] . ", 2, 2, 3, '2008-01-10', 'Direct Transfer', 'Soprano', 0, 50, 'USD'),\n        ( " . $randomContacts[39] . ", 3, 4, 1, '2009-12-14', 'Credit Card', 'Tiny-tots (ages 5-8)', 0, 800, 'USD'),\n        ( " . $randomContacts[40] . ", 1, 4, 2, '2009-01-21', 'Credit Card', 'Single', 0, 50, 'USD'),\n        ( " . $randomContacts[41] . ", 2, 2, 3, '2009-12-15', 'Credit Card', 'Soprano', 0, 50, 'USD'),\n        ( " . $randomContacts[42] . ", 3, 3, 1, '2009-03-05', 'Credit Card', 'Tiny-tots (ages 5-8)', 0, 800, 'USD'),\n        ( " . $randomContacts[43] . ", 1, 2, 1, '2009-12-13', 'Direct Transfer', 'Single', 0, 50, 'USD'),\n        ( " . $randomContacts[44] . ", 2, 4, 1, '2009-01-10', 'Direct Transfer', 'Soprano', 0, 50, 'USD'),\n        ( " . $randomContacts[45] . ", 3, 1, 4, '2009-12-13', 'Check', 'Tiny-tots (ages 5-8)', 0, 800, 'USD'),\n        ( " . $randomContacts[46] . ", 1, 2, 3, '2009-10-21', 'Credit Card', 'Single', 0, 50, 'USD'),\n        ( " . $randomContacts[47] . ", 2, 4, 1, '2009-12-10', 'Credit Card', 'Soprano', 0, 50, 'USD'),\n        ( " . $randomContacts[48] . ", 3, 3, 1, '2009-03-11', 'Credit Card', 'Tiny-tots (ages 5-8)', 0, 800, 'USD'),\n        ( " . $randomContacts[49] . ", 3, 2, 2, '2009-04-05', 'Check', 'Tiny-tots (ages 5-8)', 0, 800, 'USD');\n";
     $this->_query($participant);
     $query = "\nINSERT INTO civicrm_activity\n    (source_record_id, activity_type_id, subject, activity_date_time, duration, location, phone_id, phone_number, details, priority_id,parent_id, is_test, status_id)\nVALUES\n    (01, 5, 'NULL', '2009-01-21 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (02, 5, 'NULL', '2008-05-07 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (03, 5, 'NULL', '2008-05-05 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (04, 5, 'NULL', '2008-10-21 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (05, 5, 'NULL', '2008-01-10 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (06, 5, 'NULL', '2008-03-05 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (07, 5, 'NULL', '2009-07-21 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (08, 5, 'NULL', '2009-03-07 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (09, 5, 'NULL', '2008-02-05 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (10, 5, 'NULL', '2008-02-01 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (11, 5, 'NULL', '2009-01-10 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (12, 5, 'NULL', '2009-03-06 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (13, 5, 'NULL', '2008-06-04 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (14, 5, 'NULL', '2008-01-10 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (15, 5, 'NULL', '2008-07-04 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (16, 5, 'NULL', '2009-01-21 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (17, 5, 'NULL', '2008-01-10 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (18, 5, 'NULL', '2009-03-05 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (19, 5, 'NULL', '2008-10-21 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (20, 5, 'NULL', '2009-01-10 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (21, 5, 'NULL', '2008-03-25 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (22, 5, 'NULL', '2009-10-21 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (23, 5, 'NULL', '2008-01-10 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (24, 5, 'NULL', '2008-03-11 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (25, 5, 'NULL', '2008-04-05 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (26, 5, 'NULL', '2009-01-21 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (27, 5, 'NULL', '2008-05-07 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (28, 5, 'NULL', '2009-12-12 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (29, 5, 'NULL', '2009-12-13 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (30, 5, 'NULL', '2009-12-14 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (31, 5, 'NULL', '2009-12-15 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (32, 5, 'NULL', '2009-07-21 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (33, 5, 'NULL', '2009-03-07 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (34, 5, 'NULL', '2009-12-15 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (35, 5, 'NULL', '2009-12-13 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (36, 5, 'NULL', '2009-01-10 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (37, 5, 'NULL', '2009-03-06 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (38, 5, 'NULL', '2009-12-13 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (39, 5, 'NULL', '2008-01-10 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (40, 5, 'NULL', '2009-12-14 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (41, 5, 'NULL', '2009-01-21 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (42, 5, 'NULL', '2009-12-15 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (43, 5, 'NULL', '2009-03-05 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (44, 5, 'NULL', '2009-12-13 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (45, 5, 'NULL', '2009-01-10 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (46, 5, 'NULL', '2009-12-13 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (47, 5, 'NULL', '2009-10-21 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (48, 5, 'NULL', '2009-12-10 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (49, 5, 'NULL', '2009-03-11 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    (50, 5, 'NULL', '2009-04-05 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 )\n    ";
     $this->_query($query);
     $activityContact = "\nINSERT INTO civicrm_activity_contact\n  (contact_id, activity_id, record_type_id)\nVALUES\n";
     $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
     $currentActivityID = CRM_Core_DAO::singleValueQuery("SELECT MAX(id) FROM civicrm_activity");
     $currentActivityID -= 50;
     $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
     for ($i = 0; $i < 50; $i++) {
         $currentActivityID++;
         $activityContact .= "({$randomContacts[$i]}, {$currentActivityID}, {$sourceID})";
         if ($i != 49) {
             $activityContact .= ", ";
         }
     }
     $this->_query($activityContact);
 }
 /**
  * Returns array of contacts who are members of the specified group.
  *
  * @param CRM_Contact $group                A valid group object (passed by reference)
  * @param array       $returnProperties     Which properties
  *                    should be included in the returned Contact object(s). If NULL,
  *                    the default set of contact properties will be
  *                    included. group_contact properties (such as 'status',
  * '                  in_date', etc.) are included automatically.Note:Do not inclue
  *                    Id releted properties.
  * @param text        $status               A valid status value ('Added', 'Pending', 'Removed').
  * @param text        $sort                 Associative array of
  *                    one or more "property_name"=>"sort direction"
  *                    pairs which will control order of Contact objects returned.
  * @param Int         $offset               Starting row index.
  * @param Int         $row_count            Maximum number of rows to returns.
  *
  *
  * @return            $contactArray         Array of contacts who are members of the specified group
  *
  * @access public
  */
 static function getGroupContacts(&$group, $returnProperties = NULL, $status = 'Added', $sort = NULL, $offset = NULL, $row_count = NULL, $includeChildGroups = FALSE)
 {
     $groupDAO = new CRM_Contact_DAO_Group();
     $groupDAO->id = $group->id;
     if (!$groupDAO->find(TRUE)) {
         return CRM_Core_Error::createError("Could not locate group with id: {$id}");
     }
     // make sure user has got permission to view this group
     if (!CRM_Contact_BAO_Group::checkPermission($groupDAO->id, $groupDAO->title)) {
         return CRM_Core_Error::createError("You do not have permission to access group with id: {$id}");
     }
     $query = '';
     if (empty($returnProperties)) {
         $query = "SELECT contact_a.id as contact_id,\n                      civicrm_email.email as email";
     } else {
         $query = "SELECT contact_a.id as contact_id , {$grpStatus} as status,";
         $query .= implode(',', $returnProperties);
     }
     $params = array();
     if ($includeChildGroups) {
         $groupIds = CRM_Contact_BAO_GroupNesting::getDescendentGroupIds(array($group->id));
     } else {
         $groupIds = array($group->id);
     }
     foreach ($groupIds as $groupId) {
         $params[] = array('group', 'IN', array($group->id => TRUE), 0, 0);
     }
     $tables = array(CRM_Core_BAO_Email::getTableName() => TRUE, CRM_Contact_BAO_Contact::getTableName() => TRUE);
     $inner = array();
     $whereTables = array();
     $where = CRM_Contact_BAO_Query::getWhereClause($params, NULL, $tables, $whereTables);
     $permission = CRM_Core_Permission::whereClause(CRM_Core_Permission::VIEW, $tables, $whereTables);
     $from = CRM_Contact_BAO_Query::fromClause($tables, $inner);
     $query .= " {$from} WHERE {$permission} AND {$where} ";
     if ($sort != NULL) {
         $order = array();
         foreach ($sort as $key => $direction) {
             $order[] = " {$key} {$direction} ";
         }
         $query .= " ORDER BY " . implode(',', $order);
     }
     if (!is_null($offset) && !is_null($row_count)) {
         $query .= " LIMIT {$offset}, {$row_count}";
     }
     $dao = new CRM_Contact_DAO_Contact();
     $dao->query($query);
     // this is quite inefficient, we need to change the return
     // values in docs
     $contactArray = array();
     while ($dao->fetch()) {
         $contactArray[] = clone $dao;
     }
     return $contactArray;
 }
 function addMembership()
 {
     $contact = new CRM_Contact_DAO_Contact();
     $contact->query("SELECT id FROM civicrm_contact where contact_type = 'Individual'");
     while ($contact->fetch()) {
         $contacts[] = $contact->id;
     }
     shuffle($contacts);
     $randomContacts = array_slice($contacts, 0, 350);
     $sources = array('Payment', 'Donation', 'Check');
     $membershipTypes = array(2, 1);
     $membershipTypeNames = array('Student', 'General');
     $statuses = array(3, 4);
     $membership = "\n INSERT INTO civicrm_membership\n        (contact_id, membership_type_id, join_date, start_date, end_date, source, status_id)\nVALUES\n ";
     $activity = "\nINSERT INTO civicrm_activity\n        (source_contact_id, source_record_id, activity_type_id, subject, activity_date_time, duration, location, phone_id, phone_number, details, priority_id,parent_id, is_test, status_id)\nVALUES\n";
     foreach ($randomContacts as $count => $dontCare) {
         $source = self::_getRandomElement($sources);
         $acititySourceId = $count + 1;
         if (($count + 1) % 11 == 0) {
             // lifetime membership, status can be anything
             $startDate = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d') - $count, date('Y')));
             $membership .= "( {$randomContacts[$count]}, 3, '{$startDate}', '{$startDate}', null, '{$source}', 1)";
             $activity .= "( {$randomContacts[$count]}, {$acititySourceId}, 7, 'Lifetime', '{$startDate} 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 )";
         } elseif (($count + 1) % 5 == 0) {
             // Grace or expired, memberhsip type is random of 1 & 2
             $randId = array_rand($membershipTypes);
             $membershipType = self::_getRandomElement($membershipTypes);
             $startDate = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d') - $count * ($randId + 1) * ($randId + 1) * ($randId + 1), date('Y') - ($randId + 1)));
             $partOfDate = explode('-', $startDate);
             $endDate = date('Y-m-d', mktime(0, 0, 0, $partOfDate[1], $partOfDate[2] - 1, $partOfDate[0] + ($randId + 1)));
             $membership .= "( {$randomContacts[$count]}, {$membershipType}, '{$startDate}', '{$startDate}', '{$endDate}', '{$source}', {$statuses[$randId]})";
             $activity .= "( {$randomContacts[$count]}, {$acititySourceId}, 7, '{$membershipTypeNames[$randId]}', '{$startDate} 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 )";
         } elseif (($count + 1) % 2 == 0) {
             // membership type 2
             $startDate = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d') - $count, date('Y')));
             $endDate = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d') - $count, date('Y') + 1));
             $membership .= "( {$randomContacts[$count]}, 2, '{$startDate}', '{$startDate}', '{$endDate}', '{$source}', 1)";
             $activity .= "( {$randomContacts[$count]}, {$acititySourceId}, 7, 'Student', '{$startDate} 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 )";
         } else {
             // membership type 1
             $startDate = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d') - $count, date('Y')));
             $endDate = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d') - $count, date('Y') + 2));
             $membership .= "( {$randomContacts[$count]}, 1, '{$startDate}', '{$startDate}', '{$endDate}', '{$source}', 1)";
             $activity .= "( {$randomContacts[$count]}, {$acititySourceId}, 7, 'General', '{$startDate} 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 )";
         }
         if ($count != 349) {
             $membership .= ",";
             $activity .= ",";
         }
     }
     CRM_Core_DAO::executeQuery($membership, CRM_Core_DAO::$_nullArray);
     CRM_Core_DAO::executeQuery($activity, CRM_Core_DAO::$_nullArray);
 }
Exemplo n.º 4
0
 function addParticipant()
 {
     $contact = new CRM_Contact_DAO_Contact();
     $contact->query("SELECT id FROM civicrm_contact");
     while ($contact->fetch()) {
         $contacts[] = $contact->id;
     }
     shuffle($contacts);
     $randomContacts = array_slice($contacts, 20, 50);
     $participant = "\nINSERT INTO civicrm_participant\n        (contact_id, event_id, status_id, role_id, register_date, source, fee_level, is_test, fee_amount, fee_currency)\nVALUES\n        ( " . $randomContacts[0] . ", 1, 1, 1, '2006-01-21', 'Check', 'Single', 0, 50, 'USD'),\n        ( " . $randomContacts[1] . ", 2, 2, 2, '2005-05-07', 'Credit Card', 'Soprano', 0, 50, 'USD'),\n        ( " . $randomContacts[2] . ", 3, 3, 3, '2005-05-05', 'Credit Card', 'Tiny-tots (ages 5-8)', 0, 800, 'USD') ,\n        ( " . $randomContacts[3] . ", 1, 4, 4, '2005-10-21', 'Direct Transfer', 'Single', 0, 50, 'USD'),\n        ( " . $randomContacts[4] . ", 2, 1, 1, '2005-01-10', 'Check', 'Soprano', 0, 50, 'USD'),\n        ( " . $randomContacts[5] . ", 3, 2, 2, '2005-03-05', 'Direct Transfer', 'Tiny-tots (ages 5-8)', 0, 800, 'USD'),\n        ( " . $randomContacts[6] . ", 1, 3, 3, '2006-07-21', 'Direct Transfer', 'Single', 0, 50, 'USD'),\n        ( " . $randomContacts[7] . ", 2, 4, 4, '2006-03-07', 'Credit Card', 'Soprano', 0, 50, 'USD'),\n        ( " . $randomContacts[8] . ", 3, 1, 1, '2005-02-05', 'Direct Transfer', 'Tiny-tots (ages 5-8)', 0, 800, 'USD'),\n        ( " . $randomContacts[9] . ", 1, 2, 2, '2005-02-01', 'Check', 'Single', 0, 50, 'USD'),\n        ( " . $randomContacts[10] . ", 2, 3, 3, '2006-01-10', 'Direct Transfer', 'Soprano', 0, 50, 'USD'),\n        ( " . $randomContacts[11] . ", 3, 4, 4, '2006-03-06', 'Credit Card', 'Tiny-tots (ages 5-8)', 0, 800, 'USD'),\n        ( " . $randomContacts[12] . ", 1, 1, 2, '2005-06-04', 'Credit Card', 'Single', 0, 50, 'USD'),\n        ( " . $randomContacts[13] . ", 2, 2, 3, '2004-01-10', 'Direct Transfer', 'Soprano', 0, 50, 'USD'),\n        ( " . $randomContacts[14] . ", 3, 4, 1, '2005-07-04', 'Check', 'Tiny-tots (ages 5-8)', 0, 800, 'USD'),\n        ( " . $randomContacts[15] . ", 1, 4, 2, '2006-01-21', 'Credit Card', 'Single', 0, 50, 'USD'),\n        ( " . $randomContacts[16] . ", 2, 2, 3, '2005-01-10', 'Credit Card', 'Soprano', 0, 50, 'USD'),\n        ( " . $randomContacts[17] . ", 3, 3, 1, '2006-03-05', 'Credit Card', 'Tiny-tots (ages 5-8)', 0, 800, 'USD'),\n        ( " . $randomContacts[18] . ", 1, 2, 1, '2005-10-21', 'Direct Transfer', 'Single', 0, 50, 'USD'),\n        ( " . $randomContacts[19] . ", 2, 4, 1, '2006-01-10', 'Credit Card', 'Soprano', 0, 50, 'USD'),\n        ( " . $randomContacts[20] . ", 3, 1, 4, '2005-03-25', 'Check', 'Tiny-tots (ages 5-8)', 0, 800, 'USD'),\n        ( " . $randomContacts[21] . ", 1, 2, 3, '2006-10-21', 'Direct Transfer', 'Single', 0, 50, 'USD'),\n        ( " . $randomContacts[22] . ", 2, 4, 1, '2005-01-10', 'Direct Transfer', 'Soprano', 0, 50, 'USD'),\n        ( " . $randomContacts[23] . ", 3, 3, 1, '2005-03-11', 'Credit Card', 'Tiny-tots (ages 5-8)', 0, 800, 'USD'),\n        ( " . $randomContacts[24] . ", 3, 2, 2, '2005-04-05', 'Direct Transfer', 'Tiny-tots (ages 5-8)', 0, 800, 'USD'),\n        ( " . $randomContacts[25] . ", 1, 1, 1, '2006-01-21', 'Check', 'Single', 0, 50, 'USD'),\n        ( " . $randomContacts[26] . ", 2, 2, 2, '2007-05-07', 'Credit Card', 'Soprano', 0, 50, 'USD'),\n        ( " . $randomContacts[27] . ", 3, 3, 3, '2007-05-05', 'Direct Transfer', 'Tiny-tots (ages 5-8)', 0, 800, 'USD'),\n        ( " . $randomContacts[28] . ", 1, 4, 4, '2007-10-21', 'Credit Card', 'Single', 0, 50, 'USD'),\n        ( " . $randomContacts[29] . ", 2, 1, 1, '2007-01-10', 'Direct Transfer', 'Soprano', 0, 50, 'USD'),\n        ( " . $randomContacts[30] . ", 3, 2, 2, '2007-03-05', 'Credit Card', 'Tiny-tots (ages 5-8)', 0, 800, 'USD'),\n        ( " . $randomContacts[31] . ", 1, 3, 3, '2006-07-21', 'Check', 'Single', 0, 50, 'USD'),\n        ( " . $randomContacts[32] . ", 2, 4, 4, '2006-03-07', 'Direct Transfer', 'Soprano', 0, 50, 'USD'),\n        ( " . $randomContacts[33] . ", 3, 1, 1, '2007-02-05', 'Credit Card', 'Tiny-tots (ages 5-8)', 0, 800, 'USD'),\n        ( " . $randomContacts[34] . ", 1, 2, 2, '2007-02-01', 'Direct Transfer', 'Single', 0, 50, 'USD'),\n        ( " . $randomContacts[35] . ", 2, 3, 3, '2006-01-10', 'Direct Transfer', 'Soprano', 0, 50, 'USD'),\n        ( " . $randomContacts[36] . ", 3, 4, 4, '2006-03-06', 'Check', 'Tiny-tots (ages 5-8)', 0, 800, 'USD'),\n        ( " . $randomContacts[37] . ", 1, 1, 2, '2007-06-04', 'Direct Transfer', 'Single', 0, 50, 'USD'),\n        ( " . $randomContacts[38] . ", 2, 2, 3, '2004-01-10', 'Direct Transfer', 'Soprano', 0, 50, 'USD'),\n        ( " . $randomContacts[39] . ", 3, 4, 1, '2007-07-04', 'Credit Card', 'Tiny-tots (ages 5-8)', 0, 800, 'USD'),\n        ( " . $randomContacts[40] . ", 1, 4, 2, '2006-01-21', 'Credit Card', 'Single', 0, 50, 'USD'),\n        ( " . $randomContacts[41] . ", 2, 2, 3, '2007-01-10', 'Credit Card', 'Soprano', 0, 50, 'USD'),\n        ( " . $randomContacts[42] . ", 3, 3, 1, '2006-03-05', 'Credit Card', 'Tiny-tots (ages 5-8)', 0, 800, 'USD'),\n        ( " . $randomContacts[43] . ", 1, 2, 1, '2007-10-21', 'Direct Transfer', 'Single', 0, 50, 'USD'),\n        ( " . $randomContacts[44] . ", 2, 4, 1, '2006-01-10', 'Direct Transfer', 'Soprano', 0, 50, 'USD'),\n        ( " . $randomContacts[45] . ", 3, 1, 4, '2007-03-25', 'Check', 'Tiny-tots (ages 5-8)', 0, 800, 'USD'),\n        ( " . $randomContacts[46] . ", 1, 2, 3, '2006-10-21', 'Credit Card', 'Single', 0, 50, 'USD'),\n        ( " . $randomContacts[47] . ", 2, 4, 1, '2007-01-10', 'Credit Card', 'Soprano', 0, 50, 'USD'),\n        ( " . $randomContacts[48] . ", 3, 3, 1, '2007-03-11', 'Credit Card', 'Tiny-tots (ages 5-8)', 0, 800, 'USD'),\n        ( " . $randomContacts[49] . ", 3, 2, 2, '2007-04-05', 'Check', 'Tiny-tots (ages 5-8)', 0, 800, 'USD');\n";
     CRM_Core_DAO::executeQuery($participant, CRM_Core_DAO::$_nullArray);
     $query = "\nINSERT INTO civicrm_activity\n    (source_contact_id, source_record_id, activity_type_id, subject, activity_date_time, duration, location, phone_id, phone_number, details, priority_id,parent_id, is_test, status_id)\nVALUES\n    ({$randomContacts['0']}, 01, 5, 'NULL', '2006-01-21 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['1']}, 02, 5, 'NULL', '2005-05-07 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['2']}, 03, 5, 'NULL', '2005-05-05 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['3']}, 04, 5, 'NULL', '2005-10-21 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['4']}, 05, 5, 'NULL', '2005-01-10 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['5']}, 06, 5, 'NULL', '2005-03-05 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['6']}, 07, 5, 'NULL', '2006-07-21 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['7']}, 08, 5, 'NULL', '2006-03-07 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['8']}, 09, 5, 'NULL', '2005-02-05 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['9']}, 10, 5, 'NULL', '2005-02-01 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['10']}, 11, 5, 'NULL', '2006-01-10 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['11']}, 12, 5, 'NULL', '2006-03-06 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['12']}, 13, 5, 'NULL', '2005-06-04 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['13']}, 14, 5, 'NULL', '2004-01-10 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['14']}, 15, 5, 'NULL', '2005-07-04 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['15']}, 16, 5, 'NULL', '2006-01-21 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['16']}, 17, 5, 'NULL', '2005-01-10 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['17']}, 18, 5, 'NULL', '2006-03-05 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['18']}, 19, 5, 'NULL', '2005-10-21 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['19']}, 20, 5, 'NULL', '2006-01-10 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['20']}, 21, 5, 'NULL', '2005-03-25 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['21']}, 22, 5, 'NULL', '2006-10-21 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['22']}, 23, 5, 'NULL', '2005-01-10 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['23']}, 24, 5, 'NULL', '2005-03-11 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['24']}, 25, 5, 'NULL', '2005-04-05 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['25']}, 26, 5, 'NULL', '2006-01-21 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['26']}, 27, 5, 'NULL', '2007-05-07 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['27']}, 28, 5, 'NULL', '2005-05-05 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['28']}, 29, 5, 'NULL', '2007-10-21 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['29']}, 30, 5, 'NULL', '2007-01-10 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['30']}, 31, 5, 'NULL', '2007-03-05 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['31']}, 32, 5, 'NULL', '2006-07-21 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['32']}, 33, 5, 'NULL', '2006-03-07 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['33']}, 34, 5, 'NULL', '2007-02-05 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['34']}, 35, 5, 'NULL', '2007-02-01 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['35']}, 36, 5, 'NULL', '2006-01-10 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['36']}, 37, 5, 'NULL', '2006-03-06 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['37']}, 38, 5, 'NULL', '2007-06-04 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['38']}, 39, 5, 'NULL', '2004-01-10 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['39']}, 40, 5, 'NULL', '2007-07-04 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['40']}, 41, 5, 'NULL', '2006-01-21 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['41']}, 42, 5, 'NULL', '2007-01-10 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['42']}, 43, 5, 'NULL', '2006-03-05 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['43']}, 44, 5, 'NULL', '2007-10-21 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['44']}, 45, 5, 'NULL', '2006-01-10 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['45']}, 46, 5, 'NULL', '2007-03-25 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['46']}, 47, 5, 'NULL', '2006-10-21 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['47']}, 48, 5, 'NULL', '2006-01-10 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['48']}, 49, 5, 'NULL', '2007-03-11 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 ),\n    ({$randomContacts['49']}, 50, 5, 'NULL', '2007-04-05 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 )\n    ";
     CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
 }