Merge pull request #2342 from totten/4.4-cache-codegen
[civicrm-core.git] / sql / GenerateReportData.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
26 */
27
28 /**
29 *
30 * @package CRM
31 * @copyright CiviCRM LLC (c) 2004-2013
32 * $Id$
33 *
34 */
35
36 /*******************************************************
37 * This class generates data for the schema located in Contact.sql
38 *
39 * each public method generates data for the concerned table.
40 * so for example the addContactDomain method generates and adds
41 * data to the contact_domain table
42 *
43 * Data generation is a bit tricky since the data generated
44 * randomly in one table could be used as a FKEY in another
45 * table.
46 *
47 * In order to ensure that a randomly generated FKEY matches
48 * a field in the referened table, the field in the referenced
49 * table is always generated linearly.
50 *
51 *
52 *
53 *
54 * Some numbers
55 *
56 * Domain ID's - 1 to NUM_DOMAIN
57 *
58 * Context - 3/domain
59 *
60 * Contact - 1 to NUM_CONTACT
61 * 75% - Individual
62 * 15% - Household
63 * 10% - Organization
64 *
65 * Contact to Domain distribution should be equal.
66 *
67 *
68 * Contact Individual = 1 to 0.75*NUM_CONTACT
69 *
70 * Contact Household = 0.75*NUM_CONTACT to 0.9*NUM_CONTACT
71 *
72 * Contact Organization = 0.9*NUM_CONTACT to NUM_CONTACT
73 *
74 * Contact Location = 15% for Households, 10% for Organizations, (75-(15*4))% for Individuals.
75 * (Assumption is that each household contains 4 individuals)
76 *
77 *******************************************************/
78
79 /*******************************************************
80 *
81 * Note: implication of using of mt_srand(1) in constructor
82 * The data generated will be done in a consistent manner
83 * so as to give the same data during each run (but this
84 * would involve populating the entire db at one go - since
85 * mt_srand(1) is in the constructor, if one needs to be able
86 * to get consistent random numbers then the mt_srand(1) shld
87 * be in each function that adds data to each table.
88 *
89 *******************************************************/
90
91
92 require_once '../civicrm.config.php';
93
94 require_once 'CRM/Core/Config.php';
95 require_once 'CRM/Core/Error.php';
96 require_once 'CRM/Core/I18n.php';
97
98 require_once 'CRM/Core/DAO/Address.php';
99 require_once 'CRM/Core/DAO.php';
100 require_once 'CRM/Core/DAO/Phone.php';
101 require_once 'CRM/Core/DAO/Email.php';
102 require_once 'CRM/Core/DAO/EntityTag.php';
103 require_once 'CRM/Core/DAO/Note.php';
104 require_once 'CRM/Core/DAO/Domain.php';
105
106 require_once 'CRM/Contact/DAO/Group.php';
107 require_once 'CRM/Contact/DAO/GroupContact.php';
108 require_once 'CRM/Contact/DAO/SubscriptionHistory.php';
109 require_once 'CRM/Contact/DAO/Contact.php';
110 require_once 'CRM/Contact/DAO/Relationship.php';
111 require_once 'CRM/Event/DAO/Participant.php';
112 require_once 'CRM/Contribute/DAO/ContributionSoft.php';
113 require_once 'CRM/Member/DAO/MembershipPayment.php';
114 class CRM_GCD {
115
116 /*******************************************************
117 * constants
118 *******************************************************/
119 CONST DATA_FILENAME = "sample_data.xml";
120 CONST NUM_DOMAIN = 1;
121 CONST NUM_CONTACT = 5000;
122 CONST NUM_CONTRIBUTION = 2000;
123 CONST NUM_MEMBERSHIP = 2000;
124 CONST NUM_PARTICIPANT = 2000;
125 CONST INDIVIDUAL_PERCENT = 75;
126 CONST HOUSEHOLD_PERCENT = 15;
127 CONST ORGANIZATION_PERCENT = 10;
128 CONST NUM_INDIVIDUAL_PER_HOUSEHOLD = 4;
129 CONST NUM_ACTIVITY = 150;
130
131 // relationship types from the table crm_relationship_type
132 CONST CHILD_OF = 1;
133 CONST SPOUSE_OF = 2;
134 CONST SIBLING_OF = 3;
135 CONST HEAD_OF_HOUSEHOLD = 6;
136 CONST MEMBER_OF_HOUSEHOLD = 7;
137
138
139 // location types from the table crm_location_type
140 CONST HOME = 1;
141 CONST WORK = 2;
142 CONST MAIN = 3;
143 CONST OTHER = 4;
144 CONST ADD_TO_DB = TRUE;
145 //const ADD_TO_DB=FALSE;
146 CONST DEBUG_LEVEL = 1;
147
148 /*********************************
149 * private members
150 *********************************/
151
152 // enum's from database
153 private $preferredCommunicationMethod = array('1', '2', '3', '4', '5');
154 private $contactType = array('Individual', 'Household', 'Organization');
155 private $phoneType = array('1', '2', '3', '4');
156
157 // customizable enums (foreign keys)
158 private $prefix = array(1 => 'Mrs', 2 => 'Ms', 3 => 'Mr', 4 => 'Dr');
159 private $suffix = array(1 => 'Jr', 2 => 'Sr');
160 private $gender = array(1 => 'Female', 2 => 'Male');
161 private $greetingType = array(1 => 'Dear [first]', 2 => 'Dear [prefix] [first] [last]', 3 => 'Dear [prefix] [last]');
162
163 // store domain id's
164 private $domain = array();
165
166 // store contact id's
167 private $contact = array();
168 private $individual = array();
169 private $household = array();
170 private $organization = array();
171
172
173 // store names, firstnames, street 1, street2
174 private $firstName = array();
175 private $lastName = array();
176 private $streetName = array();
177 private $supplementalAddress1 = array();
178 private $city = array();
179 private $state = array();
180 private $country = array();
181 private $addressDirection = array();
182 private $streetType = array();
183 private $emailDomain = array();
184 private $emailTLD = array();
185 private $organizationName = array();
186 private $organizationField = array();
187 private $organizationType = array();
188 private $group = array();
189 private $note = array();
190 private $activity_type = array();
191 private $module = array();
192 private $callback = array();
193 private $party_registration = array();
194 private $degree = array();
195 private $school = array();
196
197 // stores the strict individual id and household id to individual id mapping
198 private $strictIndividual = array();
199 private $householdIndividual = array();
200
201 // sample data in xml format
202 private $sampleData = NULL;
203
204 // private vars
205 private $numIndividual = 0;
206 private $numHousehold = 0;
207 private $numOrganization = 0;
208 private $numStrictIndividual = 0;
209
210 private $CSC = array(
211 // united states
212 1228 => array(
213 // california
214 1004 => array('San Francisco', 'Los Angeles', 'Palo Alto'),
215 // new york
216 1031 => array('New York', 'Albany'),
217 ),
218 // india
219 1101 => array(
220 // maharashtra
221 1113 => array('Mumbai', 'Pune', 'Nasik'),
222 // karnataka
223 1114 => array('Bangalore', 'Mangalore', 'Udipi'),
224 ),
225 // poland
226 1172 => array(
227 // mazowieckie
228 1115 => array('Warszawa', 'PÅ‚ock'),
229 // pomorskie
230 1116 => array('Gdańsk', 'Gdynia'),
231 ),
232 );
233
234 private $groupMembershipStatus = array('Added', 'Removed', 'Pending');
235 private $subscriptionHistoryMethod = array('Admin', 'Email');
236
237 /*********************************
238 * private methods
239 *********************************/
240
241 // get a randomly generated string
242 private function _getRandomString($size = 32) {
243 $string = "";
244
245 // get an ascii code for each character
246 for ($i = 0; $i < $size; $i++) {
247 $random_int = mt_rand(65, 122);
248 if (($random_int < 97) && ($random_int > 90)) {
249 // if ascii code between 90 and 97 substitute with space
250 $random_int = 32;
251 }
252 $random_char = chr($random_int);
253 $string .= $random_char;
254 }
255 return $string;
256 }
257
258 private function _getRandomChar() {
259 return chr(mt_rand(65, 90));
260 }
261
262 private function getRandomBoolean() {
263 return mt_rand(0, 1);
264 }
265
266 private function _getRandomElement(&$array1) {
267 return $array1[mt_rand(1, count($array1)) - 1];
268 }
269
270 private function _getRandomIndex(&$array1) {
271 return mt_rand(1, count($array1));
272 }
273
274
275 // country state city combo
276 private function _getRandomCSC() {
277 $array1 = array();
278
279 // $c = array_rand($this->CSC);
280 $c = 1228;
281
282 // the state array now
283 $s = array_rand($this->CSC[$c]);
284
285 // the city
286 $ci = array_rand($this->CSC[$c][$s]);
287 $city = $this->CSC[$c][$s][$ci];
288
289 $array1[] = $c;
290 $array1[] = $s;
291 $array1[] = $city;
292
293 return $array1;
294 }
295
296 /**
297 * Generate a random date.
298 *
299 * If both $startDate and $endDate are defined generate
300 * date between them.
301 *
302 * If only startDate is specified then date generated is
303 * between startDate + 1 year.
304 *
305 * if only endDate is specified then date generated is
306 * between endDate - 1 year.
307 *
308 * if none are specified - date is between today - 1year
309 * and today
310 *
311 * @param int $startDate Start Date in Unix timestamp
312 * @param int $endDate End Date in Unix timestamp
313 * @access private
314 *
315 * @return string randomly generated date in the format "Ymd"
316 *
317 */
318 private function _getRandomDate($startDate = 0, $endDate = 0) {
319
320 // number of seconds per year
321 // $numSecond = 31536000;
322 // number of seconds for 2 year
323 $numSecond = 63072000;
324
325 $dateFormat = "Ymdhis";
326 $today = time();
327
328 // both are defined
329 if ($startDate && $endDate) {
330 return date($dateFormat, mt_rand($startDate, $endDate));
331 }
332
333 // only startDate is defined
334 if ($startDate) {
335 // $nextYear = mktime(0, 0, 0, date("m", $startDate), date("d", $startDate), date("Y")+1);
336 return date($dateFormat, mt_rand($startDate, $startDate + $numSecond));
337 }
338
339 // only endDate is defined
340 if ($startDate) {
341 return date($dateFormat, mt_rand($endDate - $numSecond, $endDate));
342 }
343
344 // none are defined
345 return date($dateFormat, mt_rand($today - $numSecond, $today));
346 }
347
348
349 // insert data into db's
350 private function _insert(&$dao) {
351 if (self::ADD_TO_DB) {
352 if (!$dao->insert()) {
353 echo "ERROR INSERT: " . mysql_error() . "\n";
354 print_r($dao);
355 exit(1);
356 }
357 }
358 }
359
360 // update data into db's
361 private function _update($dao) {
362 if (self::ADD_TO_DB) {
363 if (!$dao->update()) {
364 echo "ERROR UPDATE: " . mysql_error() . "\n";
365 print_r($dao);
366 exit(1);
367 }
368 }
369 }
370
371 /**
372 * Insert a note
373 *
374 * Helper function which randomly populates "note" and
375 * "date_modified" and inserts it.
376 *
377 * @param CRM_DAO_Note DAO object for Note
378 * @access private
379 *
380 * @return none
381 *
382 */
383 private function _insertNote($note) {
384 $note->note = $this->_getRandomElement($this->note);
385 $note->modified_date = $this->_getRandomDate();
386 $this->_insert($note);
387 }
388
389 /*******************************************************
390 *
391 * Start of public functions
392 *
393 *******************************************************/
394 // constructor
395 function __construct() {
396
397 // initialize all the vars
398 $this->numIndividual = self::INDIVIDUAL_PERCENT * self::NUM_CONTACT / 100;
399 $this->numHousehold = self::HOUSEHOLD_PERCENT * self::NUM_CONTACT / 100;
400 $this->numOrganization = self::ORGANIZATION_PERCENT * self::NUM_CONTACT / 100;
401 $this->numStrictIndividual = $this->numIndividual - ($this->numHousehold * self::NUM_INDIVIDUAL_PER_HOUSEHOLD);
402 }
403
404 public function parseDataFile() {
405
406 $sampleData = simplexml_load_file(self::DATA_FILENAME);
407
408 // first names
409 foreach ($sampleData->first_names->first_name as $first_name) {
410 $this->firstName[] = trim($first_name);
411 }
412
413 // last names
414 foreach ($sampleData->last_names->last_name as $last_name) {
415 $this->lastName[] = trim($last_name);
416 }
417
418 // street names
419 foreach ($sampleData->street_names->street_name as $street_name) {
420 $this->streetName[] = trim($street_name);
421 }
422
423 // supplemental address 1
424 foreach ($sampleData->supplemental_addresses_1->supplemental_address_1 as $supplemental_address_1) {
425 $this->supplementalAddress1[] = trim($supplemental_address_1);
426 }
427
428 // cities
429 foreach ($sampleData->cities->city as $city) {
430 $this->city[] = trim($city);
431 }
432
433 // address directions
434 foreach ($sampleData->address_directions->address_direction as $address_direction) {
435 $this->addressDirection[] = trim($address_direction);
436 }
437
438 // street types
439 foreach ($sampleData->street_types->street_type as $street_type) {
440 $this->streetType[] = trim($street_type);
441 }
442
443 // email domains
444 foreach ($sampleData->email_domains->email_domain as $email_domain) {
445 $this->emailDomain[] = trim($email_domain);
446 }
447
448 // email top level domain
449 foreach ($sampleData->email_tlds->email_tld as $email_tld) {
450 $this->emailTLD[] = trim($email_tld);
451 }
452
453 // organization name
454 foreach ($sampleData->organization_names->organization_name as $organization_name) {
455 $this->organization_name[] = trim($organization_name);
456 }
457
458 // organization field
459 foreach ($sampleData->organization_fields->organization_field as $organization_field) {
460 $this->organizationField[] = trim($organization_field);
461 }
462
463 // organization type
464 foreach ($sampleData->organization_types->organization_type as $organization_type) {
465 $this->organizationType[] = trim($organization_type);
466 }
467
468 // group
469 foreach ($sampleData->groups->group as $group) {
470 $this->group[] = trim($group);
471 }
472
473 // notes
474 foreach ($sampleData->notes->note as $note) {
475 $this->note[] = trim($note);
476 }
477
478 // activity type
479 foreach ($sampleData->activity_types->activity_type as $activity_type) {
480 $this->activity_type[] = trim($activity_type);
481 }
482
483
484 // module
485 foreach ($sampleData->modules->module as $module) {
486 $this->module[] = trim($module);
487 }
488
489 // callback
490 foreach ($sampleData->callbacks->callback as $callback) {
491 $this->callback[] = trim($callback);
492 }
493
494 // custom data - party registration
495 foreach ($sampleData->party_registrations->party_registration as $party_registration) {
496 $this->party_registration[] = trim($party_registration);
497 }
498
499 // custom data - degrees
500 foreach ($sampleData->degrees->degree as $degree) {
501 $this->degree[] = trim($degree);
502 }
503
504 // custom data - schools
505 foreach ($sampleData->schools->school as $school) {
506 $this->school[] = trim($school);
507 }
508
509 // custom data - issue
510 foreach ($sampleData->issue->status as $status) {
511 $this->issue[] = trim($status);
512 }
513
514 // custom data - gotv
515 require_once 'CRM/Core/BAO/CustomOption.php';
516 foreach ($sampleData->gotv->status as $status) {
517 $this->gotv[] = CRM_Core_DAO::VALUE_SEPARATOR . trim($status) . CRM_Core_DAO::VALUE_SEPARATOR;
518 }
519
520 // custom data - marital_status
521 foreach ($sampleData->marital_status->status as $status) {
522 $this->marital_status[] = trim($status);
523 }
524 }
525
526 public function getContactType($id) {
527 if (in_array($id, $this->individual)) {
528 return 'Individual';
529 }
530 if (in_array($id, $this->household)) {
531 return 'Household';
532 }
533 if (in_array($id, $this->organization)) {
534 return 'Organization';
535 }
536 }
537
538
539 public function initDB() {
540 $config = CRM_Core_Config::singleton();
541 }
542
543 /*******************************************************
544 *
545 * this function creates arrays for the following
546 *
547 * domain id
548 * contact id
549 * contact_location id
550 * contact_contact_location id
551 * contact_email uuid
552 * contact_phone_uuid
553 * contact_instant_message uuid
554 * contact_relationship uuid
555 * contact_task uuid
556 * contact_note uuid
557 *
558 *******************************************************/
559 public function initID() {
560
561 // may use this function in future if needed to get
562 // a consistent pattern of random numbers.
563
564 // get the domain and contact id arrays
565 $this->domain = range(1, self::NUM_DOMAIN);
566 shuffle($this->domain);
567 $this->contact = range(2, self::NUM_CONTACT + 1);
568 shuffle($this->contact);
569
570 // get the individual, household and organizaton contacts
571 $offset = 0;
572 $this->individual = array_slice($this->contact, $offset, $this->numIndividual);
573 $offset += $this->numIndividual;
574 $this->household = array_slice($this->contact, $offset, $this->numHousehold);
575 $offset += $this->numHousehold;
576 $this->organization = array_slice($this->contact, $offset, $this->numOrganization);
577
578 // get the strict individual contacts (i.e individual contacts not belonging to any household)
579 $this->strictIndividual = array_slice($this->individual, 0, $this->numStrictIndividual);
580
581 // get the household to individual mapping array
582 $this->householdIndividual = array_diff($this->individual, $this->strictIndividual);
583 $this->householdIndividual = array_chunk($this->householdIndividual, self::NUM_INDIVIDUAL_PER_HOUSEHOLD);
584 $this->householdIndividual = array_combine($this->household, $this->householdIndividual);
585 }
586
587 /*******************************************************
588 *
589 * addDomain()
590 *
591 * This method adds NUM_DOMAIN domains and then adds NUM_REVISION
592 * revisions for each domain with the latest revision being the last one..
593 *
594 *******************************************************/
595 public function addDomain() {
596
597 /* Add a location for domain 1 */
598
599 // FIXME FOR NEW LOCATION BLOCK STRUCTURE
600 // $this->_addLocation(self::MAIN, 1, true);
601
602 $domain = new CRM_Core_DAO_Domain();
603 for ($id = 2; $id <= self::NUM_DOMAIN; $id++) {
604 // domain name is pretty simple. it is "Domain $id"
605 $domain->name = "Domain $id";
606 $domain->description = "Description $id";
607 $domain->contact_name = $this->randomName();
608
609 // insert domain
610 $this->_insert($domain);
611 // FIXME FOR NEW LOCATION BLOCK STRUCTURE
612 // $this->_addLocation(self::MAIN, $id, true);
613 }
614 }
615
616 public function randomName() {
617 $prefix = $this->_getRandomIndex($this->prefix);
618 $first_name = ucfirst($this->_getRandomElement($this->firstName));
619 $middle_name = ucfirst($this->_getRandomChar());
620 $last_name = ucfirst($this->_getRandomElement($this->lastName));
621 $suffix = $this->_getRandomIndex($this->suffix);
622
623 return $this->prefix[$prefix] . " $first_name $middle_name $last_name " . $this->suffix[$suffix];
624 }
625
626 /*******************************************************
627 *
628 * addContact()
629 *
630 * This method adds data to the contact table
631 *
632 * id - from $contact
633 * contact_type 'Individual' 'Household' 'Organization'
634 * preferred_communication (random 1 to 3)
635 *
636 *******************************************************/
637 public function addContact() {
638
639 // add contacts
640 $contact = new CRM_Contact_DAO_Contact();
641
642 for ($id = 1; $id <= self::NUM_CONTACT; $id++) {
643 $contact->contact_type = $this->getContactType($id + 1);
644 $contact->do_not_phone = mt_rand(0, 1);
645 $contact->do_not_email = mt_rand(0, 1);
646 $contact->do_not_post = mt_rand(0, 1);
647 $contact->do_not_trade = mt_rand(0, 1);
648 $contact->preferred_communication_method = $this->_getRandomElement($this->preferredCommunicationMethod);
649 $this->_insert($contact);
650 }
651 }
652
653 /*******************************************************
654 *
655 * addIndividual()
656 *
657 * This method adds individual's data to the contact table
658 *
659 * The following fields are generated and added.
660 *
661 * contact_uuid - individual
662 * contact_rid - latest one
663 * first_name 'First Name $contact_uuid'
664 * middle_name 'Middle Name $contact_uuid'
665 * last_name 'Last Name $contact_uuid'
666 * job_title 'Job Title $contact_uuid'
667 * greeting_type - randomly select from the enum values
668 * custom_greeting - "custom greeting $contact_uuid'
669 *
670 *******************************************************/
671 public function addIndividual() {
672
673 $contact = new CRM_Contact_DAO_Contact();
674
675 for ($id = 1; $id <= $this->numIndividual; $id++) {
676 $contact->first_name = ucfirst($this->_getRandomElement($this->firstName));
677 $contact->middle_name = ucfirst($this->_getRandomChar());
678 $contact->last_name = ucfirst($this->_getRandomElement($this->lastName));
679 $contact->prefix_id = $this->_getRandomIndex($this->prefix);
680 $contact->suffix_id = $this->_getRandomIndex($this->suffix);
681 $contact->greeting_type_id = $this->_getRandomIndex($this->greetingType);
682 $contact->gender_id = $this->_getRandomIndex($this->gender);
683 $contact->birth_date = date("Ymd", mt_rand(0, time()));
684 $contact->is_deceased = mt_rand(0, 1);
685
686 $contact->id = $this->individual[($id - 1)];
687
688 // also update the sort name for the contact id.
689 $contact->display_name = trim($this->prefix[$contact->prefix_id] . " $contact->first_name $contact->middle_name $contact->last_name " . $this->suffix[$contact->suffix_id]);
690 $contact->sort_name = $contact->last_name . ', ' . $contact->first_name;
691 $contact->hash = crc32($contact->sort_name);
692 $this->_update($contact);
693 }
694 }
695
696 /*******************************************************
697 *
698 * addHousehold()
699 *
700 * This method adds household's data to the contact table
701 *
702 * The following fields are generated and added.
703 *
704 * contact_uuid - household_individual
705 * contact_rid - latest one
706 * household_name 'household $contact_uuid primary contact $primary_contact_uuid'
707 * nick_name 'nick $contact_uuid'
708 * primary_contact_uuid = $household_individual[$contact_uuid][0];
709 *
710 *******************************************************/
711 public function addHousehold() {
712
713 $contact = new CRM_Contact_DAO_Contact();
714 for ($id = 1; $id <= $this->numHousehold; $id++) {
715 $cid = $this->household[($id - 1)];
716 $contact->primary_contact_id = $this->householdIndividual[$cid][0];
717
718 // get the last name of the primary contact id
719 $individual = new CRM_Contact_DAO_Contact();
720 $individual->id = $contact->primary_contact_id;
721 $individual->find(TRUE);
722 $firstName = $individual->first_name;
723 $lastName = $individual->last_name;
724
725 // need to name the household and nick name appropriately
726 $contact->household_name = "$firstName $lastName" . "'s home";
727 $contact->nick_name = "$lastName" . "'s home";
728
729 $contact->id = $this->household[($id - 1)];
730 // need to update the sort name for the main contact table
731 $contact->display_name = $contact->sort_name = $contact->household_name;
732 $contact->hash = crc32($contact->sort_name);
733 $this->_update($contact);
734 }
735 }
736
737 /*******************************************************
738 *
739 * addOrganization()
740 *
741 * This method adds organization data to the contact table
742 *
743 * The following fields are generated and added.
744 *
745 * contact_uuid - organization
746 * contact_rid - latest one
747 * organization_name 'organization $contact_uuid'
748 * legal_name 'legal $contact_uuid'
749 * nick_name 'nick $contact_uuid'
750 * sic_code 'sic $contact_uuid'
751 * primary_contact_id - random individual contact uuid
752 *
753 *******************************************************/
754 public function addOrganization() {
755
756 $contact = new CRM_Contact_DAO_Contact();
757
758 for ($id = 1; $id <= $this->numOrganization; $id++) {
759 $contact->id = $this->organization[($id - 1)];
760 $name = $this->_getRandomElement($this->organization_name) . " " . $this->_getRandomElement($this->organization_field) . " " . $this->_getRandomElement($this->organization_type);
761 $contact->organization_name = $name;
762 $contact->primary_contact_id = $this->_getRandomElement($this->strict_individual);
763
764 // need to update the sort name for the main contact table
765 $contact->display_name = $contact->sort_name = $contact->organization_name;
766 $contact->hash = crc32($contact->sort_name);
767 $this->_update($contact);
768 }
769 }
770
771 /*******************************************************
772 *
773 * addRelationship()
774 *
775 * This method adds data to the contact_relationship table
776 *
777 * it adds the following fields
778 *
779 *******************************************************/
780 public function addRelationship() {
781
782 $relationship = new CRM_Contact_DAO_Relationship();
783
784 // all active for now.
785 $relationship->is_active = 1;
786
787 foreach ($this->householdIndividual as $household_id => $household_member) {
788 // add child_of relationship
789 // 2 for each child
790 $relationship->relationship_type_id = self::CHILD_OF;
791 $relationship->contact_id_a = $household_member[2];
792 $relationship->contact_id_b = $household_member[0];
793 $this->_insert($relationship);
794 $relationship->contact_id_a = $household_member[3];
795 $relationship->contact_id_b = $household_member[0];
796 $this->_insert($relationship);
797 $relationship->contact_id_a = $household_member[2];
798 $relationship->contact_id_b = $household_member[1];
799 $this->_insert($relationship);
800 $relationship->contact_id_a = $household_member[3];
801 $relationship->contact_id_b = $household_member[1];
802 $this->_insert($relationship);
803
804 // add spouse_of relationship 1 for both the spouses
805 $relationship->relationship_type_id = self::SPOUSE_OF;
806 $relationship->contact_id_a = $household_member[1];
807 $relationship->contact_id_b = $household_member[0];
808 $this->_insert($relationship);
809
810 // add sibling_of relationship 1 for both the siblings
811 $relationship->relationship_type_id = self::SIBLING_OF;
812 $relationship->contact_id_a = $household_member[3];
813 $relationship->contact_id_b = $household_member[2];
814 $this->_insert($relationship);
815
816 // add head_of_household relationship 1 for head of house
817 $relationship->relationship_type_id = self::HEAD_OF_HOUSEHOLD;
818 $relationship->contact_id_a = $household_member[0];
819 $relationship->contact_id_b = $household_id;
820 $this->_insert($relationship);
821
822 // add member_of_household relationship 3 for all other members
823 $relationship->relationship_type_id = self::MEMBER_OF_HOUSEHOLD;
824 $relationship->contact_id_a = $household_member[1];
825 $this->_insert($relationship);
826 $relationship->contact_id_a = $household_member[2];
827 $this->_insert($relationship);
828 $relationship->contact_id_a = $household_member[3];
829 $this->_insert($relationship);
830 }
831 }
832
833 /*******************************************************
834 *
835 * addLocation()
836 *
837 * This method adds data to the location table
838 *
839 *******************************************************/
840 public function addLocation() {
841 // strict individuals
842 foreach ($this->strictIndividual as $contactId) {
843 $this->_addLocation(self::HOME, $contactId);
844 }
845
846 //household
847 foreach ($this->household as $contactId) {
848 $this->_addLocation(self::HOME, $contactId);
849 }
850
851 //organization
852 foreach ($this->organization as $contactId) {
853 $this->_addLocation(self::MAIN, $contactId);
854 }
855
856 // some individuals.
857 $someIndividual = array_diff($this->individual, $this->strictIndividual);
858 $someIndividual = array_slice($someIndividual, 0, (int)(75 * ($this->numIndividual - $this->numStrictIndividual) / 100));
859 foreach ($someIndividual as $contactId) {
860 $this->_addLocation(self::HOME, $contactId, FALSE, TRUE);
861 }
862 }
863
864 private function _addLocation($locationTypeId, $contactId, $domain = FALSE, $isPrimary = TRUE) {
865 $this->_addAddress($locationTypeId, $contactId, $isPrimary);
866
867 // add two phones for each location
868 $this->_addPhone($locationTypeId, $contactId, '1', $isPrimary);
869 $this->_addPhone($locationTypeId, $contactId, '2', FALSE);
870
871 // need to get sort name to generate email id
872 $contact = new CRM_Contact_DAO_Contact();
873 $contact->id = $contactId;
874 $contact->find(TRUE);
875 // get the sort name of the contact
876 $sortName = $contact->sort_name;
877 if (!empty($sortName)) {
878 // add 2 email for each location
879 for ($emailId = 1; $emailId <= 2; $emailId++) {
880 $this->_addEmail($locationTypeId, $contactId, $sortName, ($emailId == 1) && $isPrimary);
881 }
882 }
883 }
884
885 private function _addAddress($locationTypeId, $contactId, $isPrimary = FALSE, $locationBlockID = NULL, $offset = 1) {
886 $addressDAO = new CRM_Core_DAO_Address();
887
888 // add addresses now currently we are adding only 1 address for each location
889 $addressDAO->location_type_id = $locationTypeId;
890 $addressDAO->contact_id = $contactId;
891 $addressDAO->is_primary = $isPrimary;
892
893 $addressDAO->street_number = mt_rand(1, 1000);
894 $addressDAO->street_number_suffix = ucfirst($this->_getRandomChar());
895 $addressDAO->street_number_predirectional = $this->_getRandomElement($this->addressDirection);
896 $addressDAO->street_name = ucwords($this->_getRandomElement($this->streetName));
897 $addressDAO->street_type = $this->_getRandomElement($this->streetType);
898 $addressDAO->street_number_postdirectional = $this->_getRandomElement($this->addressDirection);
899 $addressDAO->street_address = $addressDAO->street_number_predirectional . " " . $addressDAO->street_number . $addressDAO->street_number_suffix . " " . $addressDAO->street_name . " " . $addressDAO->street_type . " " . $addressDAO->street_number_postdirectional;
900 $addressDAO->supplemental_address_1 = ucwords($this->_getRandomElement($this->supplementalAddress1));
901
902 // some more random skips
903 // hack add lat / long for US based addresses
904 list($addressDAO->country_id, $addressDAO->state_province_id, $addressDAO->city,
905 $addressDAO->postal_code, $addressDAO->geo_code_1, $addressDAO->geo_code_2
906 ) = self::getZipCodeInfo();
907
908 //$addressDAO->county_id = 1;
909
910 $this->_insert($addressDAO);
911 }
912
913 private function _sortNameToEmail($sortName) {
914 $email = preg_replace("([^a-zA-Z0-9_-]*)", "", $sortName);
915 return $email;
916 }
917
918 private function _addPhone($locationTypeId, $contactId, $phoneType, $isPrimary = FALSE, $locationBlockID = NULL, $offset = 1) {
919 if ($contactId % 3) {
920 $phone = new CRM_Core_DAO_Phone();
921 $phone->location_type_id = $locationTypeId;
922 $phone->contact_id = $contactId;
923 $phone->is_primary = $isPrimary;
924 $phone->phone = mt_rand(11111111, 99999999);
925 $phone->phone_type_id = $phoneType;
926 $this->_insert($phone);
927 }
928 }
929
930 private function _addEmail($locationTypeId, $contactId, $sortName, $isPrimary = FALSE, $locationBlockID = NULL, $offset = 1) {
931 if ($contactId % 2) {
932 $email = new CRM_Core_DAO_Email();
933 $email->location_type_id = $locationTypeId;
934 $email->contact_id = $contactId;
935 $email->is_primary = $isPrimary;
936
937 $emailName = $this->_sortNameToEmail($sortName);
938 $emailDomain = $this->_getRandomElement($this->emailDomain);
939 $tld = $this->_getRandomElement($this->emailTLD);
940 $email->email = strtolower($emailName . "@" . $emailDomain . "." . $tld);
941 $this->_insert($email);
942 }
943 }
944
945 /*******************************************************
946 *
947 * addTagEntity()
948 *
949 * This method populates the crm_entity_tag table
950 *
951 *******************************************************/
952 public function addEntityTag() {
953
954 $entity_tag = new CRM_Core_DAO_EntityTag();
955
956 // add categories 1,2,3 for Organizations.
957 for ($i = 0; $i < $this->numOrganization; $i += 2) {
958 $org_id = $this->organization[$i];
959 // echo "org_id = $org_id\n";
960 $entity_tag->contact_id = $this->organization[$i];
961 $entity_tag->tag_id = mt_rand(1, 3);
962 $this->_insert($entity_tag);
963 }
964
965 // add categories 4,5 for Individuals.
966 for ($i = 0; $i < $this->numIndividual; $i += 2) {
967 $entity_tag->contact_id = $this->individual[$i];
968 if (($entity_tag->contact_id) % 3) {
969 $entity_tag->tag_id = mt_rand(4, 5);
970 $this->_insert($entity_tag);
971 }
972 else {
973 // some of the individuals are in both categories (4 and 5).
974 $entity_tag->tag_id = 4;
975 $this->_insert($entity_tag);
976 $entity_tag->tag_id = 5;
977 $this->_insert($entity_tag);
978 }
979 }
980 }
981
982 /*******************************************************
983 *
984 * addGroup()
985 *
986 * This method populates the crm_entity_tag table
987 *
988 *******************************************************/
989 public function addGroup() {
990 // add the 3 groups first
991 $numGroup = count($this->group);
992 require_once 'CRM/Contact/BAO/Group.php';
993 for ($i = 0; $i < $numGroup; $i++) {
994 $group = new CRM_Contact_BAO_Group();
995 $group->name = $this->group[$i];
996 $group->title = $this->group[$i];
997 $group->group_type = "\ 11\ 12\ 1";
998 $group->visibility = 'Public Pages';
999 $group->is_active = 1;
1000 $group->save();
1001 $group->buildClause();
1002 $group->save();
1003 }
1004
1005 // 60 are for newsletter
1006 for ($i = 0; $i < 60; $i++) {
1007 $groupContact = new CRM_Contact_DAO_GroupContact();
1008 // newsletter subscribers
1009 $groupContact->group_id = 2;
1010 $groupContact->contact_id = $this->individual[$i];
1011 // membership status
1012 $groupContact->status = $this->_getRandomElement($this->groupMembershipStatus);
1013
1014
1015 $subscriptionHistory = new CRM_Contact_DAO_SubscriptionHistory();
1016 $subscriptionHistory->contact_id = $groupContact->contact_id;
1017
1018 $subscriptionHistory->group_id = $groupContact->group_id;
1019 $subscriptionHistory->status = $groupContact->status;
1020 // method
1021 $subscriptionHistory->method = $this->_getRandomElement($this->subscriptionHistoryMethod);
1022 $subscriptionHistory->date = $this->_getRandomDate();
1023 if ($groupContact->status != 'Pending') {
1024 $this->_insert($groupContact);
1025 }
1026 $this->_insert($subscriptionHistory);
1027 }
1028
1029 // 15 volunteers
1030 for ($i = 0; $i < 15; $i++) {
1031 $groupContact = new CRM_Contact_DAO_GroupContact();
1032 // Volunteers
1033 $groupContact->group_id = 3;
1034 $groupContact->contact_id = $this->individual[$i + 60];
1035 // membership status
1036 $groupContact->status = $this->_getRandomElement($this->groupMembershipStatus);
1037
1038 $subscriptionHistory = new CRM_Contact_DAO_SubscriptionHistory();
1039 $subscriptionHistory->contact_id = $groupContact->contact_id;
1040 $subscriptionHistory->group_id = $groupContact->group_id;
1041 $subscriptionHistory->status = $groupContact->status;
1042 // method
1043 $subscriptionHistory->method = $this->_getRandomElement($this->subscriptionHistoryMethod);
1044 $subscriptionHistory->date = $this->_getRandomDate();
1045
1046 if ($groupContact->status != 'Pending') {
1047 $this->_insert($groupContact);
1048 }
1049 $this->_insert($subscriptionHistory);
1050 }
1051
1052 // 8 advisory board group
1053 for ($i = 0; $i < 8; $i++) {
1054 $groupContact = new CRM_Contact_DAO_GroupContact();
1055 // advisory board group
1056 $groupContact->group_id = 4;
1057 $groupContact->contact_id = $this->individual[$i * 7];
1058 // membership status
1059 $groupContact->status = $this->_getRandomElement($this->groupMembershipStatus);
1060
1061 $subscriptionHistory = new CRM_Contact_DAO_SubscriptionHistory();
1062 $subscriptionHistory->contact_id = $groupContact->contact_id;
1063 $subscriptionHistory->group_id = $groupContact->group_id;
1064 $subscriptionHistory->status = $groupContact->status;
1065 // method
1066 $subscriptionHistory->method = $this->_getRandomElement($this->subscriptionHistoryMethod);
1067 $subscriptionHistory->date = $this->_getRandomDate();
1068
1069 if ($groupContact->status != 'Pending') {
1070 $this->_insert($groupContact);
1071 }
1072 $this->_insert($subscriptionHistory);
1073 }
1074
1075 //In this function when we add groups that time we are cache the contact fields
1076 //But at the end of setup we are appending sample custom data, so for consistency
1077 //reset the cache.
1078 require_once 'CRM/Core/BAO/Cache.php';
1079 CRM_Core_BAO_Cache::deleteGroup('contact fields');
1080 }
1081
1082 /*******************************************************
1083 *
1084 * addNote()
1085 *
1086 * This method populates the crm_note table
1087 *
1088 *******************************************************/
1089 public function addNote() {
1090
1091 $note = new CRM_Core_DAO_Note();
1092 $note->entity_table = 'civicrm_contact';
1093 $note->contact_id = 1;
1094
1095 for ($i = 0; $i < self::NUM_CONTACT; $i++) {
1096 $note->entity_id = $this->contact[$i];
1097 if ($this->contact[$i] % 5 || $this->contact[$i] % 3 || $this->contact[$i] % 2) {
1098 $this->_insertNote($note);
1099 }
1100 }
1101 }
1102
1103 /*******************************************************
1104 *
1105 * addActivity()
1106 *
1107 * This method populates the crm_activity_history table
1108 *
1109 *******************************************************/
1110 public function addActivity() {
1111 $contactDAO = new CRM_Contact_DAO_Contact();
1112 $contactDAO->contact_type = 'Individual';
1113 $contactDAO->selectAdd();
1114 $contactDAO->selectAdd('id');
1115 $contactDAO->orderBy('sort_name');
1116 $contactDAO->find();
1117
1118 $count = 0;
1119 $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
1120
1121 while ($contactDAO->fetch()) {
1122 if ($count++ > 2) {
1123 break;
1124 }
1125 for ($i = 0; $i < self::NUM_ACTIVITY; $i++) {
1126 $activityDAO = new CRM_Activity_DAO_Activity();
1127 $activityDAO->source_contact_id = $contactDAO->id;
1128 $activityTypeID = mt_rand(7, 10);
1129
1130 $activityDAO->activity_type_id = $activityTypeID;
1131 $activityDAO->subject = "Subject for $activity[$activityTypeID]";
1132 $activityDAO->activity_date_time = $this->_getRandomDate();
1133 $activityDAO->duration = mt_rand(1, 6);
1134 $activityDAO->status_id = 2;
1135 $this->_insert($activityDAO);
1136
1137 $activityContactDAO = new CRM_Activity_DAO_ActivityContact();
1138 $activityContactDAO->activity_id = $activityDAO->id;
1139 $activityContactDAO->contact_id = mt_rand(1, 101);
1140 $activityContactDAO->record_type_id = CRM_Utils_Array::key('Activity Source', $activityContacts);
1141 $this->_insert($activityContactDAO);
1142
1143 if (in_array($activityTypeID, array(
1144 6, 9))) {
1145 $activityTargetDAO = new CRM_Activity_DAO_ActivityContact();
1146 $activityTargetDAO->activity_id = $activityDAO->id;
1147 $activityTargetDAO->contact_id = mt_rand(1, 101);
1148 $activityTargetDAO->record_type_id = CRM_Utils_Array::key('Activity Targets', $activityContacts);
1149 $this->_insert($activityTargetDAO);
1150 }
1151
1152 if ($activityTypeID == 7) {
1153 $activityAssignmentDAO = new CRM_Activity_DAO_ActivityContact();
1154 $activityAssignmentDAO->activity_id = $activityDAO->id;
1155 $activityAssignmentDAO->contact_id = mt_rand(1, 101);
1156 $activityAssignmentDAO->record_type_id = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
1157 $this->_insert($activityAssignmentDAO);
1158 }
1159 }
1160 }
1161 }
1162
1163 static function getZipCodeInfo() {
1164 $stateID = mt_rand(1000, 5132);
1165 $offset = mt_rand(1, 4132);
1166
1167 $query = "SELECT id, country_id from civicrm_state_province LIMIT $offset, 1";
1168 $dao = new CRM_Core_DAO();
1169 $dao->query($query);
1170 while ($dao->fetch()) {
1171 return array($dao->country_id, $dao->id);
1172 }
1173
1174 return array();
1175 }
1176
1177 static function getLatLong($zipCode) {
1178 $query = "http://maps.google.com/maps?q=$zipCode&output=js";
1179 $userAgent = "Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0";
1180
1181 $ch = curl_init();
1182 curl_setopt($ch, CURLOPT_URL, $query);
1183 curl_setopt($ch, CURLOPT_HEADER, FALSE);
1184 curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
1185 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
1186
1187 // grab URL and pass it to the browser
1188 $outstr = curl_exec($ch);
1189
1190 // close CURL resource, and free up system resources
1191 curl_close($ch);
1192
1193 $preg = "/'(<\?xml.+?)',/s";
1194 preg_match($preg, $outstr, $matches);
1195 if ($matches[1]) {
1196 $xml = simplexml_load_string($matches[1]);
1197 $attributes = $xml->center->attributes();
1198 if (!empty($attributes)) {
1199 return array((float ) $attributes['lat'], (float ) $attributes['lng']);
1200 }
1201 }
1202 return array(NULL, NULL);
1203 }
1204
1205 function addMembershipType() {
1206 $organizationDAO = new CRM_Contact_DAO_Contact();
1207 $organizationDAO->id = 5;
1208 $organizationDAO->find(TRUE);
1209 $contact_id = $organizationDAO->contact_id;
1210
1211 $membershipType = "INSERT INTO civicrm_membership_type
1212 (name, description, member_of_contact_id, financial_type_id, minimum_fee, duration_unit, duration_interval, period_type, fixed_period_start_day, fixed_period_rollover_day, relationship_type_id, relationship_direction, visibility, weight, is_active)
1213 VALUES
1214 ('General', 'Regular annual membership.', " . $contact_id . ", 3, 100, 'year', 1, 'rolling',null, null, 7, 'b_a', 'Public', 1, 1),
1215 ('Student', 'Discount membership for full-time students.', " . $contact_id . ", 1, 50, 'year', 1, 'rolling', null, null, 7, 'b_a', 'Public', 2, 1),
1216 ('Lifetime', 'Lifetime membership.', " . $contact_id . ", 2, 1200, 'lifetime', 1, 'rolling', null, null, 7, 'b_a', 'Admin', 3, 1);
1217 ";
1218 CRM_Core_DAO::executeQuery($membershipType, CRM_Core_DAO::$_nullArray);
1219 }
1220
1221 function addMembership() {
1222 $contact = new CRM_Contact_DAO_Contact();
1223 $contact->query("SELECT id FROM civicrm_contact where contact_type = 'Individual'");
1224 while ($contact->fetch()) {
1225 $contacts[] = $contact->id;
1226 }
1227 shuffle($contacts);
1228
1229 $randomContacts = array_slice($contacts, 0, 350);
1230
1231 $sources = array('Payment', 'Donation', 'Check');
1232 $membershipTypes = array(2, 1);
1233 $membershipTypeNames = array('Student', 'General');
1234 $statuses = array(3, 4);
1235
1236 $membership = "
1237 INSERT INTO civicrm_membership
1238 (contact_id, membership_type_id, join_date, start_date, end_date, source, status_id)
1239 VALUES
1240 ";
1241 $activity = "
1242 INSERT INTO civicrm_activity
1243 (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)
1244 VALUES
1245 ";
1246
1247 foreach ($randomContacts as $count => $dontCare) {
1248 $source = self::_getRandomElement($sources);
1249 $acititySourceId = $count + 1;
1250 if ((($count + 1) % 11 == 0)) {
1251 // lifetime membership, status can be anything
1252 $startDate = date('Y-m-d', mktime(0, 0, 0, date('m'), (date('d') - $count), date('Y')));
1253 $membership .= "( {$randomContacts[$count]}, 3, '{$startDate}', '{$startDate}', null, '{$source}', 1)";
1254 $activity .= "( {$randomContacts[$count]}, {$acititySourceId}, 7, 'Lifetime', '{$startDate} 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 )";
1255 }
1256 elseif (($count + 1) % 5 == 0) {
1257 // Grace or expired, memberhsip type is random of 1 & 2
1258 $randId = array_rand($membershipTypes);
1259 $membershipType = self::_getRandomElement($membershipTypes);
1260 $startDate = date('Y-m-d', mktime(0, 0, 0,
1261 date('m'),
1262 (date('d') - ($count * ($randId + 1) * ($randId + 1) * ($randId + 1))),
1263 (date('Y') - ($randId + 1))
1264 ));
1265 $partOfDate = explode('-', $startDate);
1266 $endDate = date('Y-m-d', mktime(0, 0, 0,
1267 $partOfDate[1],
1268 ($partOfDate[2] - 1),
1269 ($partOfDate[0] + ($randId + 1))
1270 ));
1271 $membership .= "( {$randomContacts[$count]}, {$membershipType}, '{$startDate}', '{$startDate}', '{$endDate}', '{$source}', {$statuses[$randId]})";
1272 $activity .= "( {$randomContacts[$count]}, {$acititySourceId}, 7, '{$membershipTypeNames[$randId]}', '{$startDate} 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 )";
1273 }
1274 elseif (($count + 1) % 2 == 0) {
1275 // membership type 2
1276 $startDate = date('Y-m-d', mktime(0, 0, 0, date('m'), (date('d') - $count), date('Y')));
1277 $endDate = date('Y-m-d', mktime(0, 0, 0, date('m'), (date('d') - $count), (date('Y') + 1)));
1278 $membership .= "( {$randomContacts[$count]}, 2, '{$startDate}', '{$startDate}', '{$endDate}', '{$source}', 1)";
1279 $activity .= "( {$randomContacts[$count]}, {$acititySourceId}, 7, 'Student', '{$startDate} 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 )";
1280 }
1281 else {
1282 // membership type 1
1283 $startDate = date('Y-m-d', mktime(0, 0, 0, date('m'), (date('d') - $count), date('Y')));
1284 $endDate = date('Y-m-d', mktime(0, 0, 0, date('m'), (date('d') - $count), (date('Y') + 2)));
1285 $membership .= "( {$randomContacts[$count]}, 1, '{$startDate}', '{$startDate}', '{$endDate}', '{$source}', 1)";
1286 $activity .= "( {$randomContacts[$count]}, {$acititySourceId}, 7, 'General', '{$startDate} 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 )";
1287 }
1288
1289 if ($count != 349) {
1290 $membership .= ",";
1291 $activity .= ",";
1292 }
1293 }
1294
1295 CRM_Core_DAO::executeQuery($membership, CRM_Core_DAO::$_nullArray);
1296
1297 CRM_Core_DAO::executeQuery($activity, CRM_Core_DAO::$_nullArray);
1298 }
1299
1300 static function repairDate($date) {
1301 $dropArray = array('-' => '', ':' => '', ' ' => '');
1302 return strtr($date, $dropArray);
1303 }
1304
1305 function addMembershipLog() {
1306 $membership = new CRM_Member_DAO_Membership();
1307 $membership->query("SELECT id FROM civicrm_membership");
1308 while ($membership->fetch()) {
1309 $ids[] = $membership->id;
1310 }
1311 require_once 'CRM/Member/DAO/MembershipLog.php';
1312 foreach ($ids as $id) {
1313 $membership = new CRM_Member_DAO_Membership();
1314 $membership->id = $id;
1315 $membershipLog = new CRM_Member_DAO_MembershipLog();
1316 if ($membership->find(TRUE)) {
1317 $membershipLog->membership_id = $membership->id;
1318 $membershipLog->status_id = $membership->status_id;
1319 $membershipLog->start_date = self::repairDate($membership->start_date);
1320 $membershipLog->end_date = self::repairDate($membership->end_date);
1321 $membershipLog->modified_id = $membership->contact_id;
1322 $membershipLog->modified_date = date("Ymd");
1323 $membershipLog->save();
1324 }
1325 $membershipLog = NULL;
1326 }
1327 }
1328
1329 function createEvent() {
1330 $event = "INSERT INTO civicrm_address ( contact_id, location_type_id, is_primary, is_billing, street_address, street_number, street_number_suffix, street_number_predirectional, street_name, street_type, street_number_postdirectional, street_unit, supplemental_address_1, supplemental_address_2, supplemental_address_3, city, county_id, state_province_id, postal_code_suffix, postal_code, usps_adc, country_id, geo_code_1, geo_code_2, timezone)
1331 VALUES
1332 ( NULL, 1, 1, 1, 'S 14S El Camino Way E', 14, 'S', NULL, 'El Camino', 'Way', NULL, NULL, NULL, NULL, NULL, 'Collinsville', NULL, 1006, NULL, '6022', NULL, 1228, 41.8328, -72.9253, NULL),
1333 ( NULL, 1, 1, 1, 'E 11B Woodbridge Path SW', 11, 'B', NULL, 'Woodbridge', 'Path', NULL, NULL, NULL, NULL, NULL, 'Dayton', NULL, 1034, NULL, '45417', NULL, 1228, 39.7531, -84.2471, NULL),
1334 ( NULL, 1, 1, 1, 'E 581O Lincoln Dr SW', 581, 'O', NULL, 'Lincoln', 'Dr', NULL, NULL, NULL, NULL, NULL, 'Santa Fe', NULL, 1030, NULL, '87594', NULL, 1228, 35.5212, -105.982, NULL)
1335 ";
1336 CRM_Core_DAO::executeQuery($event, CRM_Core_DAO::$_nullArray);
1337
1338 $sql = "SELECT id from civicrm_address where street_address = 'S 14S El Camino Way E'";
1339 $eventAdd1 = CRM_Core_DAO::singleValueQuery($sql, CRM_Core_DAO::$_nullArray);
1340 $sql = "SELECT id from civicrm_address where street_address = 'E 11B Woodbridge Path SW'";
1341 $eventAdd2 = CRM_Core_DAO::singleValueQuery($sql, CRM_Core_DAO::$_nullArray);
1342 $sql = "SELECT id from civicrm_address where street_address = 'E 581O Lincoln Dr SW'";
1343 $eventAdd3 = CRM_Core_DAO::singleValueQuery($sql, CRM_Core_DAO::$_nullArray);
1344
1345 $event = "INSERT INTO civicrm_email (contact_id, location_type_id, email, is_primary, is_billing, on_hold, hold_date, reset_date)
1346 VALUES
1347 (NULL, 1, 'development@example.org', 0, 0, 0, NULL, NULL),
1348 (NULL, 1, 'tournaments@example.org', 0, 0, 0, NULL, NULL),
1349 (NULL, 1, 'celebration@example.org', 0, 0, 0, NULL, NULL)
1350 ";
1351 CRM_Core_DAO::executeQuery($event, CRM_Core_DAO::$_nullArray);
1352
1353 $sql = "SELECT id from civicrm_email where email = 'development@example.org'";
1354 $eventEmail1 = CRM_Core_DAO::singleValueQuery($sql, CRM_Core_DAO::$_nullArray);
1355 $sql = "SELECT id from civicrm_email where email = 'tournaments@example.org'";
1356 $eventEmail2 = CRM_Core_DAO::singleValueQuery($sql, CRM_Core_DAO::$_nullArray);
1357 $sql = "SELECT id from civicrm_email where email = 'celebration@example.org'";
1358 $eventEmail3 = CRM_Core_DAO::singleValueQuery($sql, CRM_Core_DAO::$_nullArray);
1359
1360 $event = "INSERT INTO civicrm_phone (contact_id, location_type_id, is_primary, is_billing, mobile_provider_id, phone, phone_type_id)
1361 VALUES
1362 (NULL, 1, 0, 0, NULL,'204 222-1000', '1'),
1363 (NULL, 1, 0, 0, NULL,'204 223-1000', '1'),
1364 (NULL, 1, 0, 0, NULL,'303 323-1000', '1')
1365 ";
1366 CRM_Core_DAO::executeQuery($event, CRM_Core_DAO::$_nullArray);
1367
1368 $sql = "SELECT id from civicrm_phone where phone = '204 222-1000'";
1369 $eventPhone1 = CRM_Core_DAO::singleValueQuery($sql, CRM_Core_DAO::$_nullArray);
1370 $sql = "SELECT id from civicrm_phone where phone = '204 223-1000'";
1371 $eventPhone2 = CRM_Core_DAO::singleValueQuery($sql, CRM_Core_DAO::$_nullArray);
1372 $sql = "SELECT id from civicrm_phone where phone = '303 323-1000'";
1373 $eventPhone3 = CRM_Core_DAO::singleValueQuery($sql, CRM_Core_DAO::$_nullArray);
1374
1375 $event = "INSERT INTO civicrm_loc_block ( address_id, email_id, phone_id, address_2_id, email_2_id, phone_2_id)
1376 VALUES
1377 ( $eventAdd1, $eventEmail1, $eventPhone1, NULL,NULL,NULL),
1378 ( $eventAdd2, $eventEmail2, $eventPhone2, NULL,NULL,NULL),
1379 ( $eventAdd3, $eventEmail3, $eventPhone3, NULL,NULL,NULL)
1380 ";
1381
1382 CRM_Core_DAO::executeQuery($event, CRM_Core_DAO::$_nullArray);
1383
1384 $sql = "SELECT id from civicrm_loc_block where phone_id = $eventPhone1 AND email_id = $eventEmail1 AND address_id = $eventAdd1";
1385 $eventLok1 = CRM_Core_DAO::singleValueQuery($sql, CRM_Core_DAO::$_nullArray);
1386 $sql = "SELECT id from civicrm_loc_block where phone_id = $eventPhone2 AND email_id = $eventEmail2 AND address_id = $eventAdd2";
1387 $eventLok2 = CRM_Core_DAO::singleValueQuery($sql, CRM_Core_DAO::$_nullArray);
1388 $sql = "SELECT id from civicrm_loc_block where phone_id = $eventPhone3 AND email_id = $eventEmail3 AND address_id = $eventAdd3";
1389 $eventLok3 = CRM_Core_DAO::singleValueQuery($sql, CRM_Core_DAO::$_nullArray);
1390
1391 //create event fees
1392 $optionGroup = "INSERT INTO civicrm_option_group ( name, is_reserved, is_active)
1393 VALUES
1394 ( 'civicrm_event.amount.1', 0, 1),
1395 ( 'civicrm_event.amount.2', 0, 1),
1396 ( 'civicrm_event.amount.3', 0, 1)
1397 ";
1398 CRM_Core_DAO::executeQuery($optionGroup, CRM_Core_DAO::$_nullArray);
1399
1400
1401 $sql = "SELECT max(id) from civicrm_option_group where name = 'civicrm_event.amount.1'";
1402 $page1 = CRM_Core_DAO::singleValueQuery($sql, CRM_Core_DAO::$_nullArray);
1403
1404 $sql = "SELECT max(id) from civicrm_option_group where name = 'civicrm_event.amount.2'";
1405 $page2 = CRM_Core_DAO::singleValueQuery($sql, CRM_Core_DAO::$_nullArray);
1406
1407 $sql = "SELECT max(id) from civicrm_option_group where name = 'civicrm_event.amount.3'";
1408 $page3 = CRM_Core_DAO::singleValueQuery($sql, CRM_Core_DAO::$_nullArray);
1409
1410
1411 $optionValue = "INSERT INTO civicrm_option_value (option_group_id, label, value, is_default, weight, is_optgroup, is_reserved, is_active)
1412 VALUES
1413 ($page1, 'Single', '50', 0, 1, 0, 0, 1),
1414 ($page1, 'Couple', '100', 0, 2, 0, 0, 1),
1415 ($page1, 'Family', '200', 0, 3, 0, 0, 1),
1416 ($page2, 'Bass', '25', 0, 1, 0, 0, 1),
1417 ($page2, 'Tenor', '40', 0, 2, 0, 0, 1),
1418 ($page2, 'Soprano', '50', 0, 3, 0, 0, 1),
1419 ($page3, 'Tiny-tots (ages 5-8)', '800', 0, 1, 0, 0, 1),
1420 ($page3, 'Junior Stars (ages 9-12)', '1000', 0, 2, 0, 0, 1),
1421 ($page3, 'Super Stars (ages 13-18)', '1500', 0, 3, 0, 0, 1)";
1422
1423 CRM_Core_DAO::executeQuery($optionValue, CRM_Core_DAO::$_nullArray);
1424
1425 $sql = "SELECT max(id) FROM civicrm_option_value WHERE civicrm_option_value.option_group_id = $page1 AND civicrm_option_value.weight=2";
1426 $defaultFee1 = CRM_Core_DAO::singleValueQuery($sql, CRM_Core_DAO::$_nullArray);
1427
1428 $sql = "SELECT max(id) FROM civicrm_option_value WHERE civicrm_option_value.option_group_id = $page2 AND civicrm_option_value.weight=2";
1429 $defaultFee2 = CRM_Core_DAO::singleValueQuery($sql, CRM_Core_DAO::$_nullArray);
1430
1431 $sql = "SELECT max(id) FROM civicrm_option_value WHERE civicrm_option_value.option_group_id = $page3 AND civicrm_option_value.weight=2";
1432 $defaultFee3 = CRM_Core_DAO::singleValueQuery($sql, CRM_Core_DAO::$_nullArray);
1433
1434 $event = "INSERT INTO civicrm_event
1435 ( title, summary, description, event_type_id, participant_listing_id, is_public, start_date, end_date, is_online_registration, registration_link_text, max_participants, event_full_text, is_monetary, financial_type_id, is_map, is_active, fee_label, is_show_location, loc_block_id,intro_text, footer_text, confirm_title, confirm_text, confirm_footer_text, is_email_confirm, confirm_email_text, confirm_from_name, confirm_from_email, cc_confirm, bcc_confirm, default_fee_id, thankyou_title, thankyou_text, thankyou_footer_text, is_pay_later, pay_later_text, pay_later_receipt, is_multiple_registrations, allow_same_participant_emails )
1436 VALUES
1437 ( 'Fall Fundraiser Dinner', 'Kick up your heels at our Fall Fundraiser Dinner/Dance at Glen Echo Park! Come by yourself or bring a partner, friend or the entire family!', 'This event benefits our teen programs. Admission includes a full 3 course meal and wine or soft drinks. Grab your dancing shoes, bring the kids and come join the party!', 3, 1, 1, '2010-11-21 17:00:00', '2010-11-21 23:00:00', 1, 'Register Now', 100, 'Sorry! The Fall Fundraiser Dinner is full. Please call Jane at 204 222-1000 ext 33 if you want to be added to the waiting list.', 1, 4, 1, 1, 'Dinner Contribution', 1 ,$eventLok1,'Fill in the information below to join as at this wonderful dinner event.', NULL, 'Confirm Your Registration Information', 'Review the information below carefully.', NULL, 1, 'Contact the Development Department if you need to make any changes to your registration.', 'Fundraising Dept.', 'development@example.org', NULL, NULL, {$defaultFee1}, 'Thanks for Registering!', '<p>Thank you for your support. Your contribution will help us build even better tools.</p><p>Please tell your friends and colleagues about this wonderful event.</p>', '<p><a href=http://civicrm.org>Back to CiviCRM Home Page</a></p>', 1, 'I will send payment by check', 'Send a check payable to Our Organization within 3 business days to hold your reservation. Checks should be sent to: 100 Main St., Suite 3, San Francisco CA 94110', 0, 0 ),
1438 ( 'Summer Solstice Festival Day Concert', 'Festival Day is coming! Join us and help support your parks.', 'We will gather at noon, learn a song all together, and then join in a joyous procession to the pavilion. We will be one of many groups performing at this wonderful concert which benefits our city parks.', 5, 1, 1, '2011-06-01 12:00:00', '2011-06-01 17:00:00', 1, 'Register Now', 50, 'We have all the singers we can handle. Come to the pavilion anyway and join in from the audience.', 1, 2, NULL, 1, 'Festival Fee', 1, $eventLok2, 'Complete the form below and click Continue to register online for the festival. Or you can register by calling us at 204 222-1000 ext 22.', '', 'Confirm Your Registration Information', '', '', 1, 'This email confirms your registration. If you have questions or need to change your registration - please do not hesitate to call us.', 'Event Dept.', 'events@example.org', '', NULL, {$defaultFee2}, 'Thanks for Your Joining In!', '<p>Thank you for your support. Your participation will help build new parks.</p><p>Please tell your friends and colleagues about the concert.</p>', '<p><a href=http://civicrm.org>Back to CiviCRM Home Page</a></p>', 0, NULL, NULL, 1, 0 ),
1439 ( 'Rain-forest Cup Youth Soccer Tournament', 'Sign up your team to participate in this fun tournament which benefits several Rain-forest protection groups in the Amazon basin.', 'This is a FYSA Sanctioned Tournament, which is open to all USSF/FIFA affiliated organizations for boys and girls in age groups: U9-U10 (6v6), U11-U12 (8v8), and U13-U17 (Full Sided).', 3, 1, 1, '2011-12-27 07:00:00', '2011-12-29 17:00:00', 1, 'Register Now', 500, 'Sorry! All available team slots for this tournament have been filled. Contact Jill Futbol for information about the waiting list and next years event.', 1, 4, NULL, 1, 'Tournament Fees',1, $eventLok3, 'Complete the form below to register your team for this year''s tournament.', '<em>A Soccer Youth Event</em>', 'Review and Confirm Your Registration Information', '', '<em>A Soccer Youth Event</em>', 1, 'Contact our Tournament Director for eligibility details.', 'Tournament Director', 'tournament@example.org', '', NULL, {$defaultFee3}, 'Thanks for Your Support!', '<p>Thank you for your support. Your participation will help save thousands of acres of rainforest.</p>', '<p><a href=http://civicrm.org>Back to CiviCRM Home Page</a></p>', 0, NULL, NULL, 0, 0 )
1440 ";
1441 CRM_Core_DAO::executeQuery($event, CRM_Core_DAO::$_nullArray);
1442 }
1443
1444 function addParticipant() {
1445 // add participant
1446 $participant = new CRM_Event_DAO_Participant();
1447
1448 for ($id = 1; $id <= self::NUM_PARTICIPANT; $id++) {
1449 $participant->contact_id = mt_rand(1, self::NUM_CONTACT);
1450 $participant->event_id = mt_rand(1, 3);
1451 $participant->status_id = mt_rand(1, 5);
1452 $participant->role_id = mt_rand(1, 4);
1453 $participant->register_date = $this->_getRandomDate();
1454 $participant->source = "Credit Card";
1455
1456 if ($participant->event_id == 1) {
1457 $fee_level = "Single";
1458 $fee_amount = 50;
1459 }
1460 elseif ($participant->event_id == 2) {
1461 $fee_level = "Soprano";
1462 $fee_amount = 50;
1463 }
1464 else {
1465 $fee_level = "Tiny-tots (ages 5-8)";
1466 $fee_amount = 800;
1467 }
1468 $participant->fee_level = $fee_level;
1469 $participant->fee_amount = $fee_amount;
1470 $participant->is_test = 0;
1471
1472 $this->_insert($participant);
1473 }
1474 }
1475
1476 function addPCP() {
1477 $query = "
1478 INSERT INTO `civicrm_pcp`
1479 (contact_id, status_id, title, intro_text, page_text, donate_link_text, contribution_page_id, is_thermometer, is_honor_roll, goal_amount, referer, is_active)
1480 VALUES
1481 ({$this->individual[3]}, 2, 'My Personal Civi Fundraiser', 'I''m on a mission to get all my friends and family to help support my favorite open-source civic sector CRM.', '<p>Friends and family - please help build much needed infrastructure for the civic sector by supporting my personal campaign!</p>\r\n<p><a href=\"http://civicrm.org\">You can learn more about CiviCRM here</a>.</p>\r\n<p>Then click the <strong>Contribute Now</strong> button to go to our easy-to-use online contribution form.</p>', 'Contribute Now', 1, 1, 1, 5000.00, NULL, 1);
1482 ";
1483 CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
1484 }
1485
1486 function addContribution() {
1487 // add contributions
1488 $contribution = new CRM_Contribute_DAO_Contribution();
1489
1490 for ($id = 1; $id <= self::NUM_CONTRIBUTION; $id++) {
1491 $contribution->contact_id = mt_rand(1, self::NUM_CONTACT);
1492 $contribution->financial_type_id = mt_rand(1, 4);
1493 $contribution->contribution_page_id = mt_rand(1, 3);
1494 $contribution->payment_instrument_id = mt_rand(1, 5);
1495 $contribution->receive_date = $this->_getRandomDate();
1496 $contribution->total_amount = mt_rand(10, 99);
1497 $contribution->contribution_status_id = mt_rand(1, 6);
1498 $contribution->trxn_id = "#" . md5($contribution->receive_date);
1499 $this->_insert($contribution);
1500 }
1501 }
1502
1503 function addSoftContribution() {
1504 $pcpRollNickNAme = array('Jones Family', 'Annie and the kids', 'Anonymous', 'Adam Family');
1505
1506 $pcpPersonalNote = array('Helping Hands', 'Annie Helps', 'Anonymous', 'Adam Helps');
1507
1508 $softContribution = new CRM_Contribute_DAO_ContributionSoft();
1509
1510 $sql = "SELECT DISTINCT(contact_id), id, total_amount from civicrm_contribution LIMIT 200";
1511
1512 $contriInfo = CRM_Core_DAO::executeQuery($sql, CRM_Core_DAO::$_nullArray);
1513
1514 $prevContactID = NULL;
1515
1516 while ($contriInfo->fetch()) {
1517 if ($prevContactID) {
1518 $softContribution->contribution_id = $contriInfo->id;
1519 $softContribution->contact_id = $prevContactID;
1520 $softContribution->amount = $contriInfo->total_amount;
1521 $softContribution->pcp_id = 1;
1522 $softContribution->pcp_display_in_roll = 1;
1523 $softContribution->pcp_roll_nickname = $this->_getRandomElement($pcpRollNickNAme);
1524 $softContribution->pcp_personal_note = $this->_getRandomElement($pcpPersonalNote);
1525 $this->_insert($softContribution);
1526 }
1527 $prevContactID = $contriInfo->contact_id;
1528 }
1529 }
1530
1531 function addPledge() {
1532 $pledge = "INSERT INTO civicrm_pledge
1533 (contact_id, financial_type_id, contribution_page_id, amount, frequency_unit, frequency_interval, frequency_day, installments, start_date, create_date, acknowledge_date, modified_date, cancel_date, end_date, honor_contact_id, honor_type_id, status_id, is_test)
1534 VALUES
1535 (71, 1, 1, 500.00, 'month', 1, 1, 1, '2010-07-01 21:19:02', '2010-06-26 00:00:00', NULL, NULL, NULL,'2010-07-01 00:00:00', NULL, NULL, 1, 0),
1536 (43, 1, 1, 800.00, 'month', 3, 1, 4, '2010-07-01 10:11:09', '2010-06-23 10:11:14', '2010-06-23 10:11:18', NULL, NULL, '2010-04-01 10:11:40', NULL, NULL, 5, 0),
1537 (32, 1, 1, 600.00, 'month', 1, 1, 3, '2010-06-01 10:12:35', '2010-05-14 10:12:44', '2010-05-14 10:12:52', NULL, NULL, '2010-08-01 10:13:11', NULL, NULL, 5, 0);
1538 ";
1539 CRM_Core_DAO::executeQuery($pledge, CRM_Core_DAO::$_nullArray);
1540 }
1541
1542 function addPledgePayment() {
1543 $pledgePayment = "INSERT INTO civicrm_pledge_payment
1544 ( pledge_id, contribution_id, scheduled_amount, scheduled_date, reminder_date, reminder_count, status_id)
1545 VALUES
1546 (1, 10, 500.00, '2010-07-01 13:03:45', null, 0, 1),
1547 (2, 11, 200.00, '2010-07-01 10:59:35', null, 0, 1),
1548 (2, null, 200.00, '2010-10-01 10:59:35',null, 0, 2),
1549 (2, null, 200.00, '2010-01-01 10:59:35',null, 0, 2),
1550 (2, null, 200.00, '2010-04-01 10:59:35',null, 0, 2),
1551 (3, 12, 200.00, '2010-06-01 11:00:12', null, 0, 1),
1552 (3, 13, 200.00, '2010-07-01 10:59:35', '2010-06-28 10:59:41', 1, 1),
1553 (3, null, 200.00, '2010-08-01 11:00:12', null, 0, 2);
1554 ";
1555 CRM_Core_DAO::executeQuery($pledgePayment, CRM_Core_DAO::$_nullArray);
1556 }
1557
1558 function addMembershipPayment() {
1559 $amount = array('50', '100', '1200');
1560
1561 $contribution = new CRM_Contribute_DAO_Contribution();
1562 for ($id = 1; $id <= 200; $id++) {
1563 $contribution->contact_id = mt_rand(1, self::NUM_CONTACT);
1564 $contribution->financial_type_id = mt_rand(1, 4);
1565 $contribution->payment_instrument_id = mt_rand(1, 5);
1566 $contribution->receive_date = $this->_getRandomDate();
1567 $contribution->total_amount = $this->_getRandomElement($amount);
1568 $contribution->contribution_status_id = mt_rand(1, 6);
1569 $contribution->trxn_id = "#" . md5($contribution->receive_date);
1570 $this->_insert($contribution);
1571 }
1572 for ($i = 0; $i < 3; $i++) {
1573 $contributionsArray = $membershipArray = array();
1574 $contributionSQL = "
1575 SELECT id
1576 FROM civicrm_contribution
1577 WHERE contribution_page_id IS NULL AND
1578 total_amount = {$amount[$i]} limit 0, 50 ";
1579
1580 $contributionDAO = CRM_Core_DAO::executeQuery($contributionSQL, CRM_Core_DAO::$_nullArray);
1581
1582 while ($contributionDAO->fetch()) {
1583 $contributionsArray[] = $contributionDAO->id;
1584 }
1585 $j = $i + 1;
1586 $membershipSQL = "
1587 SELECT id
1588 FROM civicrm_membership
1589 WHERE civicrm_membership.membership_type_id = {$j} limit 0, 50";
1590 $membershipDAO = CRM_Core_DAO::executeQuery($membershipSQL, CRM_Core_DAO::$_nullArray);
1591
1592 while ($membershipDAO->fetch()) {
1593 $membershipArray[] = $membershipDAO->id;
1594 }
1595
1596 $payemntOBJ = new CRM_Member_DAO_MembershipPayment();
1597 foreach ($membershipArray as $key => $membershipid) {
1598 $payemntOBJ->contribution_id = $contributionsArray[$key];
1599 $payemntOBJ->membership_id = $membershipid;
1600 $this->_insert($payemntOBJ);
1601 }
1602 }
1603 }
1604 }
1605
1606 function user_access($str = NULL) {
1607 return TRUE;
1608 }
1609
1610 function module_list() {
1611 return array();
1612 }
1613
1614
1615 echo ("Starting data generation on " . date("F dS h:i:s A") . "\n");
1616 $obj1 = new CRM_GCD();
1617 $obj1->initID();
1618 $obj1->parseDataFile();
1619 $obj1->initDB();
1620 $obj1->addDomain();
1621 $obj1->addContact();
1622 $obj1->addIndividual();
1623 $obj1->addHousehold();
1624 $obj1->addOrganization();
1625 $obj1->addRelationship();
1626 $obj1->addLocation();
1627 $obj1->addEntityTag();
1628 $obj1->addGroup();
1629 $obj1->addNote();
1630 $obj1->addActivity();
1631 $obj1->addMembership();
1632 $obj1->addMembershipLog();
1633 $obj1->createEvent();
1634 $obj1->addParticipant();
1635 $obj1->addContribution();
1636 $obj1->addPCP();
1637 $obj1->addSoftContribution();
1638 $obj1->addPledge();
1639 $obj1->addPledgePayment();
1640 $obj1->addMembershipPayment();
1641 echo ("Ending data generation on " . date("F dS h:i:s A") . "\n");
1642