public function dtgHomeAddresses_Bind() { $this->dtgHomeAddresses->DataSource = $this->objHousehold->GetAddressArray(QQ::OrderBy(QQN::Address()->CurrentFlag, false, QQN::Address()->AddressTypeId)); }
/** * This will marge the specified household into this household. The passed in household will be DELETED. * All members of either household will be part of the merged household. * * The New HeadPerson must be a member of either household, or else an exception will be thrown * * All "Roles" will be reset by calling RefreshRole() on each HouseholdParticipation record. * @param Household $objHousehold * @param Person $objNewHeadPerson * @param boolean $blnTransaction whether or not to use a local transaction * @return void */ public function MergeHousehold(Household $objHousehold, Person $objNewHeadPerson, $blnTransaction = true) { // Ensure the specified HeadPerson is part of either household if (!HouseholdParticipation::LoadByPersonIdHouseholdId($objNewHeadPerson->Id, $this->Id) && !HouseholdParticipation::LoadByPersonIdHouseholdId($objNewHeadPerson->Id, $objHousehold->Id)) { throw new QCallerException('Specified HeadPerson of this newly merged Household not a member of either household'); } if ($blnTransaction) { self::GetDatabase()->TransactionBegin(); } try { // Get all the members of the Merging Hosuehold $objParticipationArray = $objHousehold->GetHouseholdParticipationArray(); // Each Home Address in the Merging Household will be set as a Prior Home address for each member $objAddressArray = $objHousehold->GetAddressArray(); foreach ($objParticipationArray as $objParticipation) { foreach ($objAddressArray as $objAddress) { $objAddress->CopyForPerson($objParticipation->Person, AddressType::Home, false); } } // Combine any household Splits foreach ($objHousehold->GetHouseholdSplitArray() as $objSplit) { if ($objSplit->SplitHouseholdId == $this->Id) { $objSplit->Delete(); } else { $objSplit->Household = $this; $objSplit->Save(); } } foreach ($objHousehold->GetHouseholdSplitAsSplitArray() as $objSplit) { if ($objSplit->HouseholdId == $this->Id) { $objSplit->Delete(); } else { $objSplit->SplitHousehold = $this; $objSplit->Save(); } } // Delete the merging household object, itself $objHousehold->Delete(); // Each Person in the Merging Household will be now be associated with This Household foreach ($objParticipationArray as $objParticipation) { $this->AssociatePerson(Person::Load($objParticipation->PersonId), null); } // Setup the New Head and Refresh Data $this->HeadPerson = $objNewHeadPerson; $this->RefreshMembers(false); $this->RefreshName(false); $this->Save(); // Refresh Roles of All Members foreach ($this->GetHouseholdParticipationArray() as $objParticipation) { $objParticipation->RefreshRole(); $objParticipation->Person->RefreshPrimaryContactInfo(); } } catch (Exception $objExc) { self::GetDatabase()->TransactionRollBack(); throw $objExc; } if ($blnTransaction) { self::GetDatabase()->TransactionCommit(); } }
/** * Similar to the codegenned GetAddressArray -- however this will retrieve ALL current and associated * Addresss. Not just personal addresses, but addresses attributed to the current home * of a given household. You must specify the household as well. If the household is invalid (e.g. * the participation doesn't exist), then this will throw. * * If NO household is passed in (or NULL), then this will return values for ALL associated households. * * @return Address[] */ public function GetAllAssociatedAddressArray(Household $objHousehold = null, $bUseCurrentFlag = true) { $objToReturn = array(); // Add Address from a specific household if ($objHousehold) { if (!HouseholdParticipation::LoadByPersonIdHouseholdId($this->intId, $objHousehold->Id)) { throw new QCallerException('Person does not exist in this household'); } foreach ($objHousehold->GetAddressArray() as $objAddress) { $objToReturn[] = $objAddress; } // Add addresses from all households } else { foreach ($this->GetHouseholdParticipationArray() as $objHouseholdParticipation) { foreach ($objHouseholdParticipation->Household->GetAddressArray() as $objAddress) { $objToReturn[] = $objAddress; } } } // Now add personal addresses foreach ($this->GetAddressArray(QQ::OrderBy(QQN::Address()->Id)) as $objAddress) { if ($bUseCurrentFlag) { if ($objAddress->CurrentFlag) { $objToReturn[] = $objAddress; } } else { $objToReturn[] = $objAddress; } } return $objToReturn; }