+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
require_once 'CRM/Event/DAO/Participant.php';
require_once 'CRM/Contribute/DAO/ContributionSoft.php';
require_once 'CRM/Member/DAO/MembershipPayment.php';
require_once 'CRM/Event/DAO/Participant.php';
require_once 'CRM/Contribute/DAO/ContributionSoft.php';
require_once 'CRM/Member/DAO/MembershipPayment.php';
class CRM_GCD {
/*******************************************************
* constants
*******************************************************/
class CRM_GCD {
/*******************************************************
* constants
*******************************************************/
- CONST DATA_FILENAME = "sample_data.xml";
- CONST NUM_DOMAIN = 1;
- CONST NUM_CONTACT = 5000;
- CONST NUM_CONTRIBUTION = 2000;
- CONST NUM_MEMBERSHIP = 2000;
- CONST NUM_PARTICIPANT = 2000;
- CONST INDIVIDUAL_PERCENT = 75;
- CONST HOUSEHOLD_PERCENT = 15;
- CONST ORGANIZATION_PERCENT = 10;
- CONST NUM_INDIVIDUAL_PER_HOUSEHOLD = 4;
- CONST NUM_ACTIVITY = 150;
+ const DATA_FILENAME = "sample_data.xml";
+ const NUM_DOMAIN = 1;
+ const NUM_CONTACT = 5000;
+ const NUM_CONTRIBUTION = 2000;
+ const NUM_MEMBERSHIP = 2000;
+ const NUM_PARTICIPANT = 2000;
+ const INDIVIDUAL_PERCENT = 75;
+ const HOUSEHOLD_PERCENT = 15;
+ const ORGANIZATION_PERCENT = 10;
+ const NUM_INDIVIDUAL_PER_HOUSEHOLD = 4;
+ const NUM_ACTIVITY = 150;
private function _getRandomChar() {
return chr(mt_rand(65, 90));
}
private function _getRandomChar() {
return chr(mt_rand(65, 90));
}
private function _getRandomElement(&$array1) {
return $array1[mt_rand(1, count($array1)) - 1];
}
private function _getRandomElement(&$array1) {
return $array1[mt_rand(1, count($array1)) - 1];
}
private function _getRandomIndex(&$array1) {
return mt_rand(1, count($array1));
}
// country state city combo
private function _getRandomIndex(&$array1) {
return mt_rand(1, count($array1));
}
// country state city combo
public function getContactType($id) {
if (in_array($id, $this->individual)) {
return 'Individual';
public function getContactType($id) {
if (in_array($id, $this->individual)) {
return 'Individual';
public function randomName() {
$prefix = $this->_getRandomIndex($this->prefix);
$first_name = ucfirst($this->_getRandomElement($this->firstName));
public function randomName() {
$prefix = $this->_getRandomIndex($this->prefix);
$first_name = ucfirst($this->_getRandomElement($this->firstName));
private function _addLocation($locationTypeId, $contactId, $domain = FALSE, $isPrimary = TRUE) {
$this->_addAddress($locationTypeId, $contactId, $isPrimary);
private function _addLocation($locationTypeId, $contactId, $domain = FALSE, $isPrimary = TRUE) {
$this->_addAddress($locationTypeId, $contactId, $isPrimary);
private function _addAddress($locationTypeId, $contactId, $isPrimary = FALSE, $locationBlockID = NULL, $offset = 1) {
$addressDAO = new CRM_Core_DAO_Address();
private function _addAddress($locationTypeId, $contactId, $isPrimary = FALSE, $locationBlockID = NULL, $offset = 1) {
$addressDAO = new CRM_Core_DAO_Address();
private function _sortNameToEmail($sortName) {
$email = preg_replace("([^a-zA-Z0-9_-]*)", "", $sortName);
return $email;
}
private function _sortNameToEmail($sortName) {
$email = preg_replace("([^a-zA-Z0-9_-]*)", "", $sortName);
return $email;
}
private function _addPhone($locationTypeId, $contactId, $phoneType, $isPrimary = FALSE, $locationBlockID = NULL, $offset = 1) {
if ($contactId % 3) {
$phone = new CRM_Core_DAO_Phone();
private function _addPhone($locationTypeId, $contactId, $phoneType, $isPrimary = FALSE, $locationBlockID = NULL, $offset = 1) {
if ($contactId % 3) {
$phone = new CRM_Core_DAO_Phone();
private function _addEmail($locationTypeId, $contactId, $sortName, $isPrimary = FALSE, $locationBlockID = NULL, $offset = 1) {
if ($contactId % 2) {
$email = new CRM_Core_DAO_Email();
private function _addEmail($locationTypeId, $contactId, $sortName, $isPrimary = FALSE, $locationBlockID = NULL, $offset = 1) {
if ($contactId % 2) {
$email = new CRM_Core_DAO_Email();
static function getZipCodeInfo() {
$stateID = mt_rand(1000, 5132);
$offset = mt_rand(1, 4132);
static function getZipCodeInfo() {
$stateID = mt_rand(1000, 5132);
$offset = mt_rand(1, 4132);
static function getLatLong($zipCode) {
$query = "http://maps.google.com/maps?q=$zipCode&output=js";
$userAgent = "Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0";
static function getLatLong($zipCode) {
$query = "http://maps.google.com/maps?q=$zipCode&output=js";
$userAgent = "Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0";
static function repairDate($date) {
$dropArray = array('-' => '', ':' => '', ' ' => '');
return strtr($date, $dropArray);
static function repairDate($date) {
$dropArray = array('-' => '', ':' => '', ' ' => '');
return strtr($date, $dropArray);