Exemplo n.º 1
0
 /**
  * Generates a single Individual record
  * @param boolean $blnMaleFlag
  * @param boolean $blnAdultFlag whether this Individual should be a child or an adult
  * @param string $strLastName optional last name
  * @return Person
  */
 protected static function GenerateIndividual($blnMaleFlag, $blnAdultFlag, $strLastName = null)
 {
     $objPerson = new Person();
     $objPerson->Gender = $blnMaleFlag ? 'M' : 'F';
     // Generate the name
     $objPerson->FirstName = $blnMaleFlag ? QDataGen::GenerateMaleFirstName() : QDataGen::GenerateFemaleFirstName();
     switch (rand(1, 10)) {
         case 1:
         case 2:
         case 3:
             $objPerson->MiddleName = chr(rand(ord('A'), ord('Z'))) . '.';
             break;
         case 4:
         case 5:
             $objPerson->MiddleName = $blnMaleFlag ? QDataGen::GenerateMaleFirstName() : QDataGen::GenerateFemaleFirstName();
             break;
     }
     $objPerson->LastName = $strLastName ? $strLastName : QDataGen::GenerateLastName();
     $objPerson->CanEmailFlag = rand(0, 1);
     $objPerson->CanMailFlag = rand(0, 1);
     $objPerson->CanPhoneFlag = rand(0, 1);
     if (!rand(0, 10)) {
         $objPerson->Nickname = $blnMaleFlag ? QDataGen::GenerateMaleFirstName() : QDataGen::GenerateFemaleFirstName();
     }
     if (!rand(0, 5) && !$blnMaleFlag) {
         $objPerson->PriorLastNames = QDataGen::GenerateLastName();
     }
     if (!rand(0, 10)) {
         $objPerson->MailingLabel = QString::FirstCharacter($objPerson->FirstName) . '. ' . $objPerson->LastName;
     }
     if (!rand(0, 10)) {
         $arrTitleArray = $blnMaleFlag ? array('Mr.', 'Dr.', 'Sir') : array('Ms.', 'Miss', 'Mrs.', 'Dr.', 'Lady');
         $objPerson->Title = QDataGen::GenerateFromArray($arrTitleArray);
     }
     if (!rand(0, 10)) {
         $arrSuffixArray = array('Sr.', 'Jr.', 'III', 'PhD', 'MD');
         $objPerson->Suffix = QDataGen::GenerateFromArray($arrSuffixArray);
     }
     // Date of Birth
     if ($blnAdultFlag) {
         if (rand(0, 1)) {
             $objPerson->DateOfBirth = QDataGen::GenerateDateTime(self::$LifeStartDate, self::$OldestChildBirthDate);
         }
     } else {
         $objPerson->DateOfBirth = QDataGen::GenerateDateTime(self::$OldestChildBirthDate, QDateTime::Now());
     }
     if ($objPerson->DateOfBirth) {
         $objPerson->DobGuessedFlag = !rand(0, 12);
         $objPerson->DobYearApproximateFlag = !rand(0, 12);
     }
     // Refresh Membership and Marital Statuses
     $objPerson->RefreshMembershipStatusTypeId(false);
     $objPerson->RefreshMaritalStatusTypeId(false);
     $objPerson->RefreshAge(false);
     // Setup Deceased Information
     $objPerson->DeceasedFlag = !rand(0, 200);
     if ($objPerson->DeceasedFlag && rand(0, 1)) {
         $objPerson->DateDeceased = QDataGen::GenerateDateTime(self::$LifeStartDate, QDateTime::Now());
     }
     $objPerson->Save();
     $objPerson->RefreshNameItemAssociations();
     // Head Shots
     $objHeadShotArray = array();
     $intHeadShotCount = rand(0, 3);
     for ($i = 0; $i < $intHeadShotCount; $i++) {
         $objHeadShotArray[] = $objPerson->SaveHeadShot(self::GetRandomHeadShot($objPerson->Gender == 'M'), QDataGen::GenerateDateTime(self::$SystemStartDate, QDateTime::Now()));
     }
     if (count($objHeadShotArray)) {
         $objPerson->SetCurrentHeadShot(QDataGen::GenerateFromArray($objHeadShotArray));
     }
     // Membership
     $intMembershipCount = 0;
     if ($blnAdultFlag) {
         if (!rand(0, 2)) {
             $intMembershipCount = rand(1, 3);
         }
     } else {
         if (!rand(0, 10)) {
             $intMembershipCount = rand(1, 2);
         }
     }
     if ($intMembershipCount) {
         $dttEarliestPossible = new QDateTime($objPerson->DateOfBirth ? $objPerson->DateOfBirth : self::$SystemStartDate);
         self::GenerateMembershipsForIndividual($objPerson, $dttEarliestPossible, $intMembershipCount);
     }
     // Past or non-defined marriage
     if ($blnAdultFlag && !rand(0, 10)) {
         $objMarriage = new Marriage();
         $objMarriage->Person = $objPerson;
         $objMarriage->MarriageStatusTypeId = QDataGen::GenerateFromArray(array_keys(MarriageStatusType::$NameArray));
         if (rand(0, 1)) {
             $dttStart = QDateTime::Now();
             $dttStart = QDataGen::GenerateDateTime(self::$LifeStartDate, $dttStart);
             $dttStart = QDataGen::GenerateDateTime(self::$LifeStartDate, $dttStart);
             $dttStart = QDataGen::GenerateDateTime(self::$LifeStartDate, $dttStart);
             $dttStart = QDataGen::GenerateDateTime(self::$LifeStartDate, $dttStart);
             $dttStart = QDataGen::GenerateDateTime(self::$LifeStartDate, $dttStart);
             $objMarriage->DateStart = $dttStart;
             switch ($objMarriage->MarriageStatusTypeId) {
                 case MarriageStatusType::Divorced:
                 case MarriageStatusType::Widowed:
                     $objMarriage->DateEnd = QDataGen::GenerateDateTime($dttStart, QDateTime::Now());
                     break;
             }
         }
         $objMarriage->Save();
         $objPerson->RefreshMaritalStatusTypeId();
     }
     // Comments
     $intCount = rand(0, 12);
     for ($intIndex = 0; $intIndex < $intCount; $intIndex++) {
         $dttPostDate = self::GenerateDateTime(self::$SystemStartDate, QDateTime::Now());
         $objLogin = self::GenerateFromArray(self::$UserArray);
         $objCommentCategory = self::GenerateFromArray(self::$CommentCategoryArray);
         $intCommentPrivacyTypeId = self::GenerateFromArray(array_keys(CommentPrivacyType::$NameArray));
         $strComment = self::GenerateContent(rand(1, 2), 5, 20);
         $dttActionDate = rand(0, 10) ? null : self::GenerateDateTime(self::$SystemStartDate, QDateTime::Now());
         $objPerson->SaveComment($objLogin, $strComment, $intCommentPrivacyTypeId, $objCommentCategory->Id, $dttPostDate, $dttActionDate);
     }
     // Addresses and Phone
     self::GenerateAddressesAndPhonesForPerson($objPerson);
     // Attributes
     self::GenerateAttributesForPerson($objPerson);
     return $objPerson;
 }
Exemplo n.º 2
0
 /**
  * Given this marriage record, this will update the "linked" marriage record with the same stats and details.
  * Only does anything if this marriage record has a MarriedToPerson object (otherwise, this does nothing).
  * 
  * This will CREATE the Linked Marriage record if none yet exists.
  * 
  */
 public function UpdateLinkedMarriage()
 {
     if (!$this->MarriedToPersonId) {
         return;
     }
     $objLinkedMarriage = $this->LinkedMarriage;
     if (!$objLinkedMarriage) {
         $objLinkedMarriage = new Marriage();
         $objLinkedMarriage->LinkedMarriage = $this;
         $objLinkedMarriage->Person = $this->MarriedToPerson;
         $objLinkedMarriage->MarriedToPerson = $this->Person;
     }
     $objLinkedMarriage->DateStart = $this->DateStart;
     $objLinkedMarriage->DateEnd = $this->DateEnd;
     $objLinkedMarriage->MarriageStatusTypeId = $this->intMarriageStatusTypeId;
     $objLinkedMarriage->Save();
     if (!$this->intLinkedMarriageId) {
         $this->intLinkedMarriageId = $objLinkedMarriage->Id;
         $this->Save();
     }
 }
Exemplo n.º 3
0
 /**
  * Creates a new Marriage record and refreshes the marrital status for both this person and the spouse
  * @param integer $intMarriageStatusTypeId (defaults to "Married")
  * @param Person $objSpouse the spouse
  * @param QDateTime $dttStartDate the start date of the marriage
  * @param QDateTime $dttEndDate the end date of the marriage
  * @return Marriage
  */
 public function CreateMarriageWith(Person $objSpouse = null, QDateTime $dttStartDate = null, QDateTime $dttEndDate = null, $intMarriageStatusTypeId = MarriageStatusType::Married)
 {
     $objMarriage = new Marriage();
     $objMarriage->Person = $this;
     $objMarriage->MarriedToPerson = $objSpouse;
     $objMarriage->MarriageStatusTypeId = $intMarriageStatusTypeId;
     $objMarriage->DateStart = $dttStartDate;
     $objMarriage->DateEnd = $dttEndDate;
     $objMarriage->Save();
     // Updated Link record (if applicable)
     if ($objSpouse) {
         $objMarriage->UpdateLinkedMarriage();
     }
     // Refresh Stats
     $this->RefreshMaritalStatusTypeId();
     if ($objSpouse) {
         $objSpouse->RefreshMaritalStatusTypeId();
     }
     return $objMarriage;
 }