Example #1
0
File: new.php Project: alcf/chms
 protected function btnSave_Click()
 {
     $this->pnlContent->objDelegate->mctAddress->UpdateFields();
     if ($this->pnlContent->objDelegate->mctAddress->Address->ValidateUsps()) {
         // Create the household
         $this->objHousehold = Household::CreateHousehold($this->objPerson);
         // Delete any old home phone number records
         foreach ($this->objPerson->GetPhoneArray() as $objPhone) {
             if ($objPhone->PhoneTypeId == PhoneType::Home) {
                 $objPhone->Delete();
             }
         }
     }
     // Save the address
     $this->pnlContent->btnSave_Click();
 }
Example #2
0
 /**
  * Split this household into two.  Move PersonArray into the new household and assign $objNewHeadPerson
  * as the head of the new household.
  * 
  * @param Person[] $objPersonArray
  * @param Person $objNewHeadPerson
  * @param Address $objNewAddress
  * @return Household
  */
 public function SplitHousehold($objPersonArray, Person $objNewHeadPerson, Address $objNewAddress)
 {
     $this->UnassociatePerson($objNewHeadPerson, false);
     $objNewHousehold = Household::CreateHousehold($objNewHeadPerson);
     foreach ($objPersonArray as $objPerson) {
         if ($objPerson->Id != $objNewHeadPerson->Id) {
             $this->UnassociatePerson($objPerson);
             $objNewHousehold->AssociatePerson($objPerson);
         }
     }
     // Log it
     $objHouseholdSplit = new HouseholdSplit();
     $objHouseholdSplit->Household = $this;
     $objHouseholdSplit->SplitHousehold = $objNewHousehold;
     $objHouseholdSplit->DateSplit = QDateTime::Now();
     $objHouseholdSplit->Save();
     // Set the Address
     $objNewAddress->Household = $objNewHousehold;
     $objNewAddress->Save();
     $objNewHousehold->SetAsCurrentAddress($objNewAddress);
     return $objNewHousehold;
 }
Example #3
0
 /**
  * Generates a typical Single-Family household
  * @return Household
  */
 public static function GenerateHouseholdSingleFamily()
 {
     $strLastName = QDataGen::GenerateLastName();
     $objHeadPerson = self::GenerateIndividual(rand(0, 6), true, $strLastName);
     $objHousehold = Household::CreateHousehold($objHeadPerson);
     $objHousehold->CombinedStewardshipFlag = rand(0, 7);
     $objHousehold->Save();
     // Add a Spouse
     if (rand(0, 6)) {
         $objSpouse = self::GenerateIndividual($objHeadPerson->Gender == 'M' ? false : true, true, $strLastName);
         $intMinimumChildCount = 0;
         $objHeadPerson->DeleteAllMarriages();
         $objSpouse->DeleteAllMarriages();
         if ($objHeadPerson->DateOfBirth) {
             $dttStartDate = $objHeadPerson->DateOfBirth;
         } else {
             if ($objSpouse->DateOfBirth) {
                 $dttStartDate = $objSpouse->DateOfBirth;
             } else {
                 $dttStartDate = QDataGen::GenerateDateTime(self::$LifeStartDate, QDateTime::Now());
             }
         }
         $dttStartDate = QDataGen::GenerateDateTime($dttStartDate, QDateTime::Now());
         $objHeadPerson->CreateMarriageWith($objSpouse, $dttStartDate);
         $objHousehold->AssociatePerson($objSpouse);
     } else {
         // If no spouse, we must have at least one child in order to be a "family"
         $objSpouse = null;
         $intMinimumChildCount = 1;
     }
     // Add Children (if applicable)
     $intChildCount = rand($intMinimumChildCount, 4);
     $objChildArray = array();
     for ($i = 0; $i < $intChildCount; $i++) {
         $objChild = self::GenerateIndividual(rand(0, 1), false, $strLastName);
         // Add the relationship
         $objHeadPerson->AddRelationship($objChild, RelationshipType::Child);
         if ($objSpouse) {
             $objSpouse->AddRelationship($objChild, RelationshipType::Child);
         }
         foreach ($objChildArray as $objSibling) {
             $objChild->AddRelationship($objSibling, RelationshipType::Sibling);
         }
         $objHousehold->AssociatePerson($objChild);
         $objChildArray[] = $objChild;
     }
     return $objHousehold;
 }
Example #4
0
 /**
  * Given a home (and optional mailing) address validator (which is unlinked from any db entry), go ahead and make updates
  * to this person record accordingly.
  * 
  * If this person is part of multiple households, it will throw an error.
  * 
  * If this person is part of one household, it will update the information for the household.
  * 
  * If this person is not part of any houseold, it will create one for him/her.
  * 
  * @param AddressValidator $objHomeAddressValidator
  * @param AddressValidator $objMailingAddressValidator optional
  * @param string $strHomePhone optional
  */
 public function UpdateAddressInformation(AddressValidator $objHomeAddressValidator, AddressValidator $objMailingAddressValidator = null, $strHomePhone = null)
 {
     $objHouseholdArray = array();
     foreach ($this->GetHouseholdParticipationArray() as $objHouseholdParticipation) {
         $objHouseholdArray[] = $objHouseholdParticipation->Household;
     }
     // Figure Out Household Information
     if (count($objHouseholdArray) > 1) {
         throw new QCallerException('Cannot call UpdateAddressInformation on a person who is part of multiple households: ' . $this->intId);
     }
     if (count($objHouseholdArray)) {
         $objHousehold = $objHouseholdArray[0];
     } else {
         $objHousehold = Household::CreateHousehold($this);
     }
     // Home Address
     $objHomeAddress = $objHousehold->GetCurrentAddress();
     $objAddress = $objHomeAddressValidator->CreateAddressRecord();
     // Are we using the existing Household CurrentAddress record?
     if ($objHomeAddress && $objHomeAddress->IsEqualTo($objAddress)) {
         // Yes -- so all we're handling is the phones
         $objHomePhoneArray = $objHomeAddress->GetPhoneArray();
         // Are we setting a home phone?
         if ($strHomePhone) {
             // Try and find the phone within the array
             foreach ($objHomePhoneArray as $objPhone) {
                 $blnFound = false;
                 if ($objPhone->Number == $strHomePhone) {
                     $objPhone->SetAsPrimary(null, $objHomeAddress);
                     $blnFound = true;
                 }
             }
             // If we didn't find an existing home phone, we will update the current primary (if applicable)
             // Or create a new one as primary
             if (!$blnFound) {
                 if (count($objHomePhoneArray)) {
                     $objHomePhoneArray[0]->Number = $strHomePhone;
                     $objHomePhoneArray[0]->Save();
                 } else {
                     $objPhone = new Phone();
                     $objPhone->Number = $strHomePhone;
                     $objPhone->Address = $objHomeAddress;
                     $objPhone->PhoneTypeId = PhoneType::Home;
                     $objPhone->Save();
                     $objPhone->SetAsPrimary(null, $objHomeAddress);
                 }
             }
             // Nope - we are deleting the home phone
         } else {
             foreach ($objHomePhoneArray as $objPhone) {
                 $objPhone->Delete();
             }
         }
         // Not an existing Household CurrentAddress record that matches -- so we are creating a new one
     } else {
         $objAddress->Household = $objHousehold;
         $objAddress->CurrentFlag = true;
         $objAddress->AddressTypeId = AddressType::Home;
         $objAddress->Save();
         $objHousehold->SetAsCurrentAddress($objAddress);
         // Add the phone if applicable
         if ($strHomePhone) {
             $objPhone = new Phone();
             $objPhone->Number = $strHomePhone;
             $objPhone->Address = $objAddress;
             $objPhone->PhoneTypeId = PhoneType::Home;
             $objPhone->Save();
             $objPhone->SetAsPrimary(null, $objAddress);
         }
     }
     // Mailing Address?
     if ($objMailingAddressValidator) {
         $objAddress = $objMailingAddressValidator->CreateAddressRecord();
         $blnFound = false;
         foreach ($this->GetAllAssociatedAddressArray($objHousehold) as $objExistingAddress) {
             if ($objExistingAddress->IsEqualTo($objAddress)) {
                 $this->MailingAddress = $objExistingAddress;
                 $this->RefreshPrimaryContactInfo();
                 $blnFound = true;
             }
         }
         if (!$blnFound) {
             $objAddress->AddressTypeId = AddressType::Other;
             $objAddress->Person = $this;
             $objAddress->CurrentFlag = true;
             $objAddress->Save();
             $this->MailingAddress = $objAddress;
             $this->RefreshPrimaryContactInfo();
         }
     } else {
         if ($this->MailingAddress) {
             $this->MailingAddress = null;
             $this->RefreshPrimaryContactInfo();
         }
     }
 }
Example #5
0
File: new.php Project: alcf/chms
 protected function SavePerson()
 {
     // Fixup Middle
     $this->txtPersonMiddleName->Text = trim($this->txtPersonMiddleName->Text);
     if (strlen($this->txtPersonMiddleName->Text) == 1) {
         $this->txtPersonMiddleName->Text = strtoupper($this->txtPersonMiddleName->Text);
     } else {
         if (strlen($this->txtPersonMiddleName->Text) == 2 && $this->txtPersonMiddleName->Text[1] == '.') {
             $this->txtPersonMiddleName->Text = strtoupper($this->txtPersonMiddleName->Text[0]);
         }
     }
     // Update Gender and Types and Save
     $this->mctPerson->Person->Gender = $this->lstPersonGender->SelectedValue;
     $this->mctPerson->Person->MembershipStatusTypeId = MembershipStatusType::NonMember;
     $this->mctPerson->Person->MaritalStatusTypeId = MaritalStatusType::NotSpecified;
     $this->mctPerson->Person->DeceasedFlag = false;
     $this->mctPerson->Person->CanEmailFlag = $this->lstCanEmail->SelectedValue;
     $this->mctPerson->Person->CanPhoneFlag = $this->lstCanPhone->SelectedValue;
     $this->mctPerson->Person->CanMailFlag = $this->lstCanMail->SelectedValue;
     $this->mctPerson->SavePerson();
     $this->mctPerson->Person->RefreshNameItemAssociations();
     // Is there a home address?
     if (trim($this->txtCity->Text)) {
         $objHousehold = Household::CreateHousehold($this->mctPerson->Person);
         $this->mctAddress->Address->AddressTypeId = AddressType::Home;
         $this->mctAddress->Address->Household = $objHousehold;
         $this->mctAddress->Address->CurrentFlag = true;
         $this->mctAddress->Address->InvalidFlag = false;
         $this->mctAddress->SaveAddress();
     } else {
         $objHousehold = null;
     }
     // Email
     if (trim($this->txtPersonEmail->Text)) {
         $objEmail = new Email();
         $objEmail->Person = $this->mctPerson->Person;
         $objEmail->Address = trim($this->txtPersonEmail->Text);
         $objEmail->Save();
         $this->mctPerson->Person->PrimaryEmail = $objEmail;
     }
     // Phones
     if (trim($this->txtPersonCellPhone->Text)) {
         $objPhone = new Phone();
         $objPhone->PhoneTypeId = PhoneType::Mobile;
         $objPhone->Person = $this->mctPerson->Person;
         $objPhone->Number = trim($this->txtPersonCellPhone->Text);
         $objPhone->MobileProviderId = $this->lstPersonMobileProvider->SelectedValue;
         $objPhone->Save();
         $this->mctPerson->Person->PrimaryPhone = $objPhone;
     }
     if (trim($this->txtPersonHomePhone->Text)) {
         $objPhone = new Phone();
         $objPhone->PhoneTypeId = PhoneType::Home;
         $objPhone->Number = trim($this->txtPersonHomePhone->Text);
         if ($objHousehold) {
             $objPhone->Address = $this->mctAddress->Address;
         } else {
             $objPhone->Person = $this->mctPerson->Person;
         }
         $objPhone->Save();
         if (!$this->mctPerson->Person->PrimaryPhone) {
             $this->mctPerson->Person->PrimaryPhone = $objPhone;
         }
         if ($this->mctAddress->Address->Id) {
             $this->mctAddress->Address->PrimaryPhone = $objPhone;
             $this->mctAddress->Address->Save();
         }
         $this->objHomePhone = $objPhone;
     }
     if (trim($this->txtPersonWorkPhone->Text)) {
         $objPhone = new Phone();
         $objPhone->PhoneTypeId = PhoneType::Work;
         $objPhone->Person = $this->mctPerson->Person;
         $objPhone->Number = trim($this->txtPersonWorkPhone->Text);
         $objPhone->Save();
         if (!$this->mctPerson->Person->PrimaryPhone) {
             $this->mctPerson->Person->PrimaryPhone = $objPhone;
         }
     }
 }
Example #6
0
File: index.php Project: alcf/chms
 /**
  * Called back from PaymentPanel to perform final tasks after we know
  * the payment has been submitted successfully.
  */
 public function PaymentPanel_Success(OnlineDonation $objPaymentObject)
 {
     $strEmailAddress = trim(strtolower($this->txtEmail->Text));
     // If there is a "address in waiting" for this OnlineDonation
     // Then it was a newly-created Person object
     // Let's create the household for this person
     if ($objPaymentObject->Address) {
         $objPerson = $objPaymentObject->Person;
         $objHousehold = Household::CreateHousehold($objPerson);
         $objAddress = $objPaymentObject->Address;
         $objAddress->AddressTypeId = AddressType::Home;
         $objAddress->CurrentFlag = true;
         $objAddress->Household = $objHousehold;
         $objAddress->Save();
         $objHousehold->SetAsCurrentAddress($objAddress);
         // Add Email Address
         if ($strEmailAddress) {
             $objEmail = new Email();
             $objEmail->Address = $strEmailAddress;
             $objEmail->Person = $objPerson;
             $objEmail->Save();
             $objEmail->SetAsPrimary();
         }
     }
     if (QApplication::$PublicLogin) {
         $objPaymentObject->SendConfirmationEmail();
     } else {
         if ($strEmailAddress) {
             $objPaymentObject->SendConfirmationEmail($strEmailAddress);
             $_SESSION['onlineDonationEmailAddress' . $objPaymentObject->Id] = $strEmailAddress;
         } else {
             $_SESSION['onlineDonationEmailAddress' . $objPaymentObject->Id] = null;
             unset($_SESSION['onlineDonationEmailAddress' . $objPaymentObject->Id]);
         }
     }
     QApplication::Redirect($objPaymentObject->ConfirmationUrl);
 }
Example #7
0
 public function testMergeHouseholds()
 {
     $objOldHead = $this->objMultiplePersonHousehold1->HeadPerson;
     $objHeadPerson = Person::CreatePerson('HeadOfOne', null, 'Person', true);
     $objMergeHousehold = Household::CreateHousehold($objHeadPerson);
     $this->objMultiplePersonHousehold1->MergeHousehold($objMergeHousehold, $objHeadPerson);
     $this->AssertNull(Household::Load($objMergeHousehold->Id), 'MergeHousehold did not delete merged household');
     $this->AssertEquals($this->objMultiplePersonHousehold1->CountHouseholdParticipations(), 4, 'MergeHousehold Person Count incorrect');
     $objOldHead = Person::Load($objOldHead->Id);
     $this->AssertEquals($objOldHead->GetHouseholdStatus(), Person::HouseholdStatusMemberOfOne, 'MergeHousehold OldHead Status incorrect');
     $objHeadPerson = Person::Load($objHeadPerson->Id);
     $this->AssertEquals($objHeadPerson->GetHouseholdStatus(), Person::HouseholdStatusHeadOfFamily, 'MergeHousehold NewHead Status incorrect');
     $this->objMultiplePersonHousehold1->SetAsHeadPerson($objOldHead);
     $this->objMultiplePersonHousehold1->UnassociatePerson($objHeadPerson);
     $this->AssertEquals($this->objMultiplePersonHousehold1->CountHouseholdParticipations(), 3, 'MergeHousehold Person Count incorrect');
     $objHeadPerson->Delete();
 }
 /**
  * Given data points supplied this will attempt to reconcile this PublicLogin record to an actual person... or if not possible,
  * it will create a new person record.
  * 
  * There are several stesp to this process.
  * First, do a Search of All People for the given Email
  * 		- if 1 and only 1 person was found:
  * 			+ Check the personal details of that persons record
  * 				- If matched against First/Last or Nickname/Last, setup the match
  * 				- If matched against DOB and/or Gender and/or Mobile, setup the match and update the name
  * 				- If not matched, create as new
  * 		- if no people were found
  * 			+ in all the DB, do a search to find matches against First/Last or Nickname/Last AND any address
  * 				- if exactly one is found, setup the match
  * 				- if non were found, create as new
  * 				- if multiple were found, find the first one that also match DOB and/or Gender and/or Mobile (or if none just find the first one) and setup the match
  * 		- if multiple people were found
  * 			+ WITHIN the set of found people, do a search to find matches against First/Last or Nickname/Last AND any address
  * 				- if exactly one is found, setup the match
  * 				- if non were found, create as new
  * 				- if multiple were found, find the first one that also match DOB and/or Gender and/or Mobile (or if none just find the first one) and setup the match
  * 
  * It will then check and see if the Person found (if any) already has a login object... if so, it will return that found Person record and do nothing further.
  * 
  * Otherwise, it will then update all data accordingly (including creating a new Person record, if needed) and return the Person that was created.
  * 
  * @param string $strPassword
  * @param string $strQuestion
  * @param string $strAnswer
  * @param string $strHomePhone
  * @param string $strMobilePhone
  * @param Address $objHomeAddress
  * @param Address $objMailingAddress optional
  * @param QDateTime $dttDateOfBirth optional
  * @param string $strGenderFlag optional
  * @return Person the person that was matched
  */
 public function Reconcile($strPassword, $strQuestion, $strAnswer, $strHomePhone, $strMobilePhone, Address $objHomeAddress, Address $objMailingAddress = null, QDateTime $dttDateOfBirth = null, $strGenderFlag = null)
 {
     // Try and Find a Person based on Email
     $objPersonArray = array();
     foreach (Email::LoadArrayByAddress($this->strEmailAddress) as $objEmail) {
         $objPersonArray[] = $objEmail->Person;
     }
     // Let's try and find a single Person object to reconcile for
     // 1 and only 1 person was found with the email
     if (count($objPersonArray) == 1) {
         if ($objPersonArray[0]->IsNameMatch($this->FirstName, $this->LastName)) {
             $objPerson = $objPersonArray[0];
         } else {
             if ($objPersonArray[0]->ScoreDobGenderMobileMatch($dttDateOfBirth, $strGenderFlag, $strMobilePhone) > 0) {
                 $objPerson = $objPersonArray[0];
             } else {
                 $objPerson = null;
             }
         }
         // MORE than one person was found with the email
     } else {
         if (count($objPersonArray)) {
             // Go through each of them and find a name-match and address-match
             $objMatchedPersonArray = array();
             foreach ($objPersonArray as $objPerson) {
                 if ($objPerson->IsNameAndAddressMatch($this->FirstName, $this->LastName, $objHomeAddress, $objMailingAddress)) {
                     $objMatchedPersonArray[] = $objPerson;
                 }
             }
             if (count($objMatchedPersonArray) == 1) {
                 $objPerson = $objMatchedPersonArray[0];
             } else {
                 if (!count($objMatchedPersonArray)) {
                     $objPerson = null;
                 } else {
                     $objPerson = $objMatchedPersonArray[0];
                     $intCurrentScore = 0;
                     foreach ($objMatchedPersonArray as $objMatchedPerson) {
                         $intScore = $objMatchedPerson->ScoreDobGenderMobileMatch($dttDateOfBirth, $strGenderFlag, $strMobilePhone);
                         if ($intScore > $intCurrentScore) {
                             $intCurrentScore = $intScore;
                             $objPerson = $objMatchedPerson;
                         }
                     }
                 }
             }
             // NO ONE was found with the email
         } else {
             // First pull the ones with Name Matched
             $objPersonArray = Person::LoadArrayByNameMatch($this->FirstName, $this->LastName);
             // Go through each of those and find address-match records
             $objMatchedPersonArray = array();
             foreach ($objPersonArray as $objPerson) {
                 if ($objPerson->IsNameAndAddressMatch($this->FirstName, $this->LastName, $objHomeAddress, $objMailingAddress)) {
                     $objMatchedPersonArray[] = $objPerson;
                 }
             }
             if (count($objMatchedPersonArray) == 1) {
                 $objPerson = $objMatchedPersonArray[0];
             } else {
                 if (!count($objMatchedPersonArray)) {
                     $objPerson = null;
                 } else {
                     $objPerson = $objMatchedPersonArray[0];
                     $intCurrentScore = 0;
                     foreach ($objMatchedPersonArray as $objMatchedPerson) {
                         $intScore = $objMatchedPerson->ScoreDobGenderMobileMatch($dttDateOfBirth, $strGenderFlag, $strMobilePhone);
                         if ($intScore > $intCurrentScore) {
                             $intCurrentScore = $intScore;
                             $objPerson = $objMatchedPerson;
                         }
                     }
                 }
             }
         }
     }
     // If we have a person, make sure it's not already linked
     if ($objPerson) {
         if ($objPerson->PublicLogin) {
             return $objPerson;
         }
     }
     // We now have either a unlinked Person record or no person record
     // Let's make all the DB updates we need to
     Person::GetDatabase()->TransactionBegin();
     // Do we have a single Person object?
     // If not, let's create it
     if (!$objPerson) {
         $blnMaleFlag = null;
         if ($strGenderFlag = trim(strtoupper($strGenderFlag))) {
             $blnMaleFlag = $strGenderFlag == 'M';
         }
         $intPhoneTypeId = $strMobilePhone ? PhoneType::Mobile : null;
         $objPerson = Person::CreatePerson($this->FirstName, null, $this->LastName, $blnMaleFlag, $this->EmailAddress, $strMobilePhone, $intPhoneTypeId);
         $objPerson->DateOfBirth = $dttDateOfBirth;
         if ($objPerson->DateOfBirth) {
             $objPerson->DobGuessedFlag = false;
             $objPerson->DobYearApproximateFlag = false;
         }
         $objPerson->PublicCreationFlag = true;
         $objPerson->Save();
     }
     //////////////////////////////////
     // Let's update the information
     //////////////////////////////////
     // Email Address
     $objPerson->ChangePrimaryEmailTo($this->EmailAddress, false);
     // Gender and DOB
     if ($strGenderFlag = trim(strtoupper($strGenderFlag))) {
         $objPerson->Gender = $strGenderFlag;
     }
     if ($dttDateOfBirth) {
         $objPerson->DateOfBirth = $dttDateOfBirth;
         $objPerson->DobGuessedFlag = false;
         $objPerson->DobYearApproximateFlag = false;
     }
     // Mobile Phone
     if ($strMobilePhone) {
         $blnFound = false;
         foreach ($objPerson->GetAllAssociatedPhoneArray() as $objPhone) {
             if ($objPhone->Number == $strMobilePhone) {
                 $objPhone->PhoneTypeId = PhoneType::Mobile;
                 $objPhone->Save();
                 $blnFound = true;
             }
         }
         if (!$blnFound) {
             $objPhone = new Phone();
             $objPhone->Number = $strMobilePhone;
             $objPhone->PhoneTypeId = PhoneType::Mobile;
             $objPhone->Save();
             $objPerson->PrimaryPhone = $objPhone;
         }
     }
     // Mailing Address
     if ($objMailingAddress) {
         $blnFound = false;
         foreach ($objPerson->GetAllAssociatedAddressArray() as $objAddress) {
             if ($objAddress->IsEqualTo($objMailingAddress)) {
                 $blnFound = true;
                 $objAddress->CurrentFlag = true;
                 $objAddress->AddressTypeId = AddressType::Other;
                 $objAddress->Save();
                 $objPerson->MailingAddress = $objAddress;
                 $objPerson->StewardshipAddress = $objAddress;
             }
         }
         if (!$blnFound) {
             $objMailingAddress->Person = $objPerson;
             $objMailingAddress->CurrentFlag = true;
             $objMailingAddress->AddressTypeId = AddressType::Other;
             $objMailingAddress->Save();
             $objPerson->MailingAddress = $objMailingAddress;
             $objPerson->StewardshipAddress = $objMailingAddress;
         }
     }
     // Home Address and Phone
     $objHouseholdParticipationArray = $objPerson->GetHouseholdParticipationArray();
     if (count($objHouseholdParticipationArray) == 1) {
         $objHousehold = $objHouseholdParticipationArray[0]->Household;
         $objAddress = $objHousehold->GetCurrentAddress();
         if ($objAddress && $objAddress->IsEqualTo($objHomeAddress)) {
             $objHomeAddress = $objAddress;
         } else {
             $objHomeAddress->AddressTypeId = AddressType::Home;
             $objHomeAddress->Household = $objHousehold;
             $objHomeAddress->CurrentFlag = true;
             $objHomeAddress->Save();
             if ($objAddress) {
                 $objAddress->CurrentFlag = false;
                 $objAddress->Save();
             }
         }
         if ($strHomePhone) {
             $blnFound = false;
             foreach ($objHomeAddress->GetPhoneArray() as $objPhone) {
                 if ($objPhone->Number == $strHomePhone) {
                     $blnFound = true;
                     $objPhone->SetAsPrimary(null, $objHomeAddress);
                 }
             }
             if (!$blnFound) {
                 $objPhone = new Phone();
                 $objPhone->PhoneTypeId = PhoneType::Home;
                 $objPhone->Number = $strHomePhone;
                 $objPhone->Address = $objHomeAddress;
                 $objPhone->Save();
                 $objPhone->SetAsPrimary(null, $objHomeAddress);
             }
         }
     } else {
         if (count($objHouseholdParticipationArray) == 0) {
             $objHousehold = Household::CreateHousehold($objPerson);
             $objHomeAddress->AddressTypeId = AddressType::Home;
             $objHomeAddress->Household = $objHousehold;
             $objHomeAddress->CurrentFlag = true;
             $objHomeAddress->Save();
             $objHousehold->SetAsCurrentAddress($objHomeAddress);
             if ($strHomePhone) {
                 $objPhone = new Phone();
                 $objPhone->PhoneTypeId = PhoneType::Home;
                 $objPhone->Number = $strHomePhone;
                 $objPhone->Address = $objHomeAddress;
                 $objPhone->Save();
                 $objPhone->SetAsPrimary(null, $objHomeAddress);
             }
         }
     }
     // Wire to PublicLogin
     $this->PublicLogin->Person = $objPerson;
     $this->PublicLogin->SetPassword($strPassword);
     $this->PublicLogin->LostPasswordQuestion = trim($strQuestion);
     $this->PublicLogin->LostPasswordAnswer = trim(strtolower($strAnswer));
     $this->PublicLogin->DateLastLogin = QDateTime::Now();
     $this->PublicLogin->Save();
     // Save the person and delete the provision
     $objPerson->RefreshPrimaryContactInfo();
     $objPerson->RefreshAge(false);
     $objPerson->RefreshNameItemAssociations(true);
     $this->Delete();
     // Commit to DB
     Person::GetDatabase()->TransactionCommit();
     // Return the now-linked person!
     return $objPerson;
 }