*
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
- * $Id$
- *
*/
/**
private $groupMembershipStatus = array('Added', 'Removed', 'Pending');
private $subscriptionHistoryMethod = array('Admin', 'Email');
+ private $deceasedContactIds = array();
/*********************************
* private methods
}
// Deceased probability based on age
- if ($age > 40) {
+ if ($contact->gender_id && $contact->gender_id == 2) {
+ $checkAge = 64;
+ }
+ else {
+ $checkAge = 68;
+ }
+ if ($age > $checkAge && count($this->deceasedContactIds) < 4) {
$contact->is_deceased = $this->probability(($age - 30) / 100);
if ($contact->is_deceased && $this->probability(.7)) {
$contact->deceased_date = $this->randomDate();
$contact->hash = crc32($contact->sort_name);
$contact->id = $cid;
$this->_update($contact);
+ if ($contact->is_deceased) {
+ $this->deceasedContactIds[] = $cid;
+ }
}
}
}
}
- $offset = mt_rand(1, 43000);
- $query = "SELECT city, state, zip, latitude, longitude FROM zipcodes LIMIT $offset, 1";
- $dao = new CRM_Core_DAO();
- $dao->query($query);
- while ($dao->fetch()) {
- if ($this->stateMap[$dao->state]) {
- $stateID = $this->stateMap[$dao->state];
- }
- else {
- $stateID = 1004;
- }
+ static $zipCodes = NULL;
+ if ($zipCodes === NULL) {
+ $zipCodes = json_decode(file_get_contents(__DIR__ . '/zipcodes.json'));
+ }
+
+ $zipCode = $zipCodes[mt_rand(0, count($zipCodes))];
- $zip = str_pad($dao->zip, 5, '0', STR_PAD_LEFT);
- return array(1228, $stateID, $dao->city, $zip, $dao->latitude, $dao->longitude);
+ if ($this->stateMap[$zipCode->state]) {
+ $stateID = $this->stateMap[$zipCode->state];
}
+ else {
+ $stateID = 1004;
+ }
+
+ $zip = str_pad($zipCode->zip, 5, '0', STR_PAD_LEFT);
+ return array(1228, $stateID, $zipCode->city, $zip, $zipCode->latitude, $zipCode->longitude);
}
/**