public function testAssociateAndUnassociatePerson() { $this->objMultiplePersonHousehold1->AssociatePerson($this->objIndividual); $this->AssertEquals($this->objMultiplePersonHousehold1->CountHouseholdParticipations(), 4, 'AssociatePerson Count incorrect'); $this->AssertEquals($this->objIndividual->GetHouseholdStatus(), Person::HouseholdStatusMemberOfOne, 'AssociatePerson HouseholdStatusMemberOfOne incorrect'); $this->AssertNotNull(HouseholdParticipation::LoadByPersonIdHouseholdId($this->objIndividual->Id, $this->objMultiplePersonHousehold1->Id), 'AssociatePerson failed'); $objOldHead = $this->objMultiplePersonHousehold1->HeadPerson; $this->objMultiplePersonHousehold1->SetAsHeadPerson($this->objIndividual); $this->AssertEquals($this->objIndividual->GetHouseholdStatus(), Person::HouseholdStatusHeadOfFamily, 'AssociatePerson HouseholdStatusHeadOfFamily incorrect'); $this->objMultiplePersonHousehold1->SetAsHeadPerson($objOldHead); $this->objIndividual = Person::Load($this->objIndividual->Id); $this->AssertEquals($this->objIndividual->GetHouseholdStatus(), Person::HouseholdStatusMemberOfOne, 'AssociatePerson HouseholdStatusMemberOfOne incorrect'); $this->objMultiplePersonHousehold1->UnassociatePerson($this->objIndividual); $this->AssertEquals($this->objIndividual->GetHouseholdStatus(), Person::HouseholdStatusNone, 'UnassociatePerson HouseholdStatusNone failed'); }
protected function Form_Create() { $this->objHousehold = Household::Load(QApplication::PathInfo(1)); if ($this->objHousehold) { if (!HouseholdParticipation::LoadByPersonIdHouseholdId($this->objPerson->Id, $this->objHousehold->Id)) { QApplication::Redirect('/individuals/'); } } else { $objHouseholdParticipationArray = HouseholdParticipation::LoadArrayByPersonId($this->objPerson->Id); if ($objHouseholdParticipationArray) { $this->objHousehold = $objHouseholdParticipationArray[0]->Household; } } $this->strPageTitle .= $this->objPerson->Name; // Unset based on Permissions if (!QApplication::$Login->IsPermissionAllowed(PermissionType::AccessStewardship)) { unset($this->strSubNavItemArray['stewardship']); } if (!QApplication::$Login->IsPermissionAllowed(PermissionType::MergeIndividuals)) { unset($this->strSubNavItemArray['merge']); } // Alter Inactive/Active based on whether or not the person has a login if ($this->objPerson->PublicLogin) { $this->strSubNavItemArray['online'][2] = null; } $this->lblHeading = new QLabel($this); $this->lblSubheading = new QLabel($this); $this->lblSubheading->CssClass = 'subhead'; $this->lblSubheading->HtmlEntities = false; $this->lstHouseholdSwitcher = new QListBox($this); $this->lstHouseholdSwitcher->SetCustomStyle('float', 'right'); $this->lstHouseholdSwitcher->SetCustomStyle('margin-top', '8px;'); $this->lstHouseholdSwitcher->Visible = false; $this->lstHouseholdSwitcher->AddAction(new QChangeEvent(), new QAjaxAction('lstHouseholdSwitcher_Change')); $this->pnlHouseholdSelector = new HouseholdSelectorPanel($this); $this->pnlSubnavBar = new ViewIndividualSubNavPanel($this); $this->pnlMainContent = new QPanel($this); $this->pnlMainContent->AutoRenderChildren = true; $this->pnlMainContent->CssClass = 'subnavContent'; $this->SetUrlHashProcessor('Form_ProcessHash'); $this->lblHeading_Refresh(); $this->lstHouseholdSwitcher_Refresh(); }
protected function btnSave_Click($strFormId, $strControlId, $strParameter) { $this->objPersonToAdd = $this->pnlPerson->Person; if (HouseholdParticipation::LoadByPersonIdHouseholdId($this->objPersonToAdd->Id, $this->objHousehold->Id)) { $this->dlgMessage->RemoveAllButtons(); $this->dlgMessage->MessageHtml = sprintf('<strong>%s</strong> is already part of this household.', QApplication::HtmlEntities($this->objPersonToAdd->Name)); $this->dlgMessage->ShowDialogBox(); return; } $this->dlgMessage->RemoveAllButtons(); switch ($this->objPersonToAdd->GetHouseholdStatus()) { case Person::HouseholdStatusNone: $this->AddToHousehold(); return; case Person::HouseholdStatusHeadOfOne: $this->MergeHouseholds(); return; case Person::HouseholdStatusHeadOfFamily: $this->dlgMessage->MessageHtml = sprintf('<strong>%s</strong> is Head of another household and thus cannot be added to this one.', QApplication::HtmlEntities($this->objPersonToAdd->Name)); break; case Person::HouseholdStatusMemberOfOne: $objParticipationArray = $this->objPersonToAdd->GetHouseholdParticipationArray(); $objHousehold = $objParticipationArray[0]->Household; $this->dlgMessage->MessageHtml = sprintf('<strong>%s</strong> is currently part of the <strong>%s</strong>.<br/><br/>Is %s <strong>moving</strong> to this household, or is %s <strong>adding</strong> this as an <em>additional</em> household?', QApplication::HtmlEntities($this->objPersonToAdd->Name), QApplication::HtmlEntities($objHousehold->Name), $this->objPersonToAdd->PronounSubject, $this->objPersonToAdd->PronounSubject); $this->dlgMessage->AddButton('Moving', MessageDialog::ButtonPrimary, 'MoveHouseholds'); $this->dlgMessage->AddButton('Adding', MessageDialog::ButtonPrimary, 'AddToHousehold'); $this->dlgMessage->AddButton('Cancel', MessageDialog::ButtonSecondary, 'HideDialogBox', $this->dlgMessage); break; case Person::HouseholdStatusMemberOfMultiple: $this->dlgMessage->MessageHtml = sprintf('<strong>%s</strong> is currently part of <strong>multiple households</strong>.<br/><br/>Are you sure you want to add %s to this household?', QApplication::HtmlEntities($this->objPersonToAdd->Name), $this->objPersonToAdd->PronounIndirectObject); $this->dlgMessage->AddButton('Yes', MessageDialog::ButtonPrimary, 'AddToHousehold'); $this->dlgMessage->AddButton('No', MessageDialog::ButtonSecondary, 'HideDialogBox', $this->dlgMessage); break; case Person::HouseholdStatusError: default: $this->dlgMessage->MessageHtml = sprintf('An unknown data error occurred while trying to add <strong>%s</strong> to this "%s" household. Please contact a ChMS Administrator to report the issue.', QApplication::HtmlEntities($this->objPersonToAdd->Name), QApplication::HtmlEntities($this->objHousehold->Name)); break; } $this->dlgMessage->ShowDialogBox(); }
case 'daughter': $intRelationshipTypeId = RelationshipType::Child; break; case 'brother': case 'sister': $intRelationshipTypeId = RelationshipType::Sibling; break; case 'grandmother': case 'grandfather': $intRelationshipTypeId = RelationshipType::Grandparent; break; case 'grandchild': case 'grandson': case 'granddaughter': $intRelationshipTypeId = RelationshipType::Grandchild; break; } if ($intRelationshipTypeId) { $objPerson = Person::Load($intPersonIdByIndvId[$objRow['indvid']]); $objRelatedPerson = Person::Load($intPersonIdByIndvId[$objRow['reltindvid']]); if (!Relationship::LoadByPersonIdRelatedToPersonId($objPerson->Id, $objRelatedPerson->Id)) { $objPerson->AddRelationship($objRelatedPerson, $intRelationshipTypeId); } } } } $objParticipationCursor = HouseholdParticipation::QueryCursor(QQ::All()); $intCount = HouseholdParticipation::CountAll(); while (QDataGen::DisplayWhileTask('Recalculating HouseholdParticipation Roles', $intCount) && ($objHouseholdParticipation = HouseholdParticipation::InstantiateCursor($objParticipationCursor))) { $objHouseholdParticipation->RefreshRole(); }
/** * Deletes all associated HouseholdParticipations * @return void */ public function DeleteAllHouseholdParticipations() { if (is_null($this->intId)) { throw new QUndefinedPrimaryKeyException('Unable to call UnassociateHouseholdParticipation on this unsaved Household.'); } // Get the Database Object for this Class $objDatabase = Household::GetDatabase(); // Journaling if ($objDatabase->JournalingDatabase) { foreach (HouseholdParticipation::LoadArrayByHouseholdId($this->intId) as $objHouseholdParticipation) { $objHouseholdParticipation->Journal('DELETE'); } } // Perform the SQL Query $objDatabase->NonQuery(' DELETE FROM `household_participation` WHERE `household_id` = ' . $objDatabase->SqlVariable($this->intId) . ' '); }
/** * Static Helper Method to Create using PK arguments * You must pass in the PK arguments on an object to load, or leave it blank to create a new one. * If you want to load via QueryString or PathInfo, use the CreateFromQueryString or CreateFromPathInfo * static helper methods. Finally, specify a CreateType to define whether or not we are only allowed to * edit, or if we are also allowed to create a new one, etc. * * @param mixed $objParentObject QForm or QPanel which will be using this HouseholdParticipationMetaControl * @param integer $intId primary key value * @param QMetaControlCreateType $intCreateType rules governing HouseholdParticipation object creation - defaults to CreateOrEdit * @return HouseholdParticipationMetaControl */ public static function Create($objParentObject, $intId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) { // Attempt to Load from PK Arguments if (strlen($intId)) { $objHouseholdParticipation = HouseholdParticipation::Load($intId); // HouseholdParticipation was found -- return it! if ($objHouseholdParticipation) { return new HouseholdParticipationMetaControl($objParentObject, $objHouseholdParticipation); } else { if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) { throw new QCallerException('Could not find a HouseholdParticipation object with PK arguments: ' . $intId); } } // If EditOnly is specified, throw an exception } else { if ($intCreateType == QMetaControlCreateType::EditOnly) { throw new QCallerException('No PK arguments specified'); } } // If we are here, then we need to create a new record return new HouseholdParticipationMetaControl($objParentObject, new HouseholdParticipation()); }
/** * Attempts to remove the person from the household. This will throw an exception if: * - This person is not currently part of the household * - This person is the only person in the household * - This person is the head of the household * @param Person $objPerson * @param boolean $blnClearAssociatedPhoneAndAddress * @return void */ public function UnassociatePerson(Person $objPerson, $blnClearAssociatedPhoneAndAddress = true) { $objParticipation = HouseholdParticipation::LoadByPersonIdHouseholdId($objPerson->Id, $this->Id); if (!$objParticipation) { throw new QCallerException('Person does not exist in the household'); } if ($this->CountHouseholdParticipations() == 1) { throw new QCallerException('Person is the only member of this household and thus cannot be removed'); } if ($this->HeadPersonId == $objPerson->Id) { throw new QCallerException('Person is the Head of this household and thus cannot be removed'); } self::GetDatabase()->TransactionBegin(); try { foreach ($this->GetAddressArray() as $objAddress) { $objAddress->CopyForPerson($objPerson, AddressType::Home, false); } $objParticipation->Delete(); $this->RefreshMembers(); } catch (Exception $objExc) { self::GetDatabase()->TransactionRollBack(); throw $objExc; } self::GetDatabase()->TransactionCommit(); // Update linked phone and address stuff if ($blnClearAssociatedPhoneAndAddress) { $intAddressIdArray = array(); $intPhoneIdArray = array(); foreach ($this->GetAddressArray() as $objAddress) { $intAddressIdArray[$objAddress->Id] = true; foreach ($objAddress->GetPhoneArray() as $objPhone) { $intPhoneIdArray[$objPhone->Id] = true; } } if (array_key_exists($objPerson->MailingAddressId, $intAddressIdArray)) { $objPerson->MailingAddress = null; } if (array_key_exists($objPerson->StewardshipAddressId, $intAddressIdArray)) { $objPerson->StewardshipAddress = null; } if (array_key_exists($objPerson->PrimaryPhoneId, $intPhoneIdArray)) { $objPerson->PrimaryPhone = null; } } $objPerson->RefreshPrimaryContactInfo(); }
public static function GetSoapArrayFromArray($objArray) { if (!$objArray) { return null; } $objArrayToReturn = array(); foreach ($objArray as $objObject) { array_push($objArrayToReturn, HouseholdParticipation::GetSoapObjectFromObject($objObject, true)); } return unserialize(serialize($objArrayToReturn)); }
/** * Merges two records together. * @param Person $objPersonMergeWith * @param boolean $blnUseThisDetails boolean on whether to use this person's Person object details, or if false, use the PersonMergeWith's */ public function MergeWith(Person $objPersonMergeWith, $blnUseThisDetails) { QLog::Log(sprintf('Merging %s (ID %s) with %s (ID %s) - %s', $this->Name, $this->Id, $objPersonMergeWith->Name, $objPersonMergeWith->Id, $blnUseThisDetails ? 'left' : 'right')); Person::GetDatabase()->TransactionBegin(); // Household Participation Records if ($this->HouseholdAsHead && $objPersonMergeWith->HouseholdAsHead) { $this->HouseholdAsHead->MergeHousehold($objPersonMergeWith->HouseholdAsHead, $this); } else { if ($this->HouseholdAsHead) { // Go through each MergeWith HouseholdParticipation -- Throw if it's another household, Delete if it's this Household-as-Head foreach ($objPersonMergeWith->GetHouseholdParticipationArray() as $objHouseholdParticipation) { if ($objHouseholdParticipation->HouseholdId != $this->HouseholdAsHead->Id) { throw new QCallerException('Cannot merge this head of household with a person record that exists in other households'); } else { $objHouseholdParticipation->Delete(); } } } else { if ($objHousehold = $objPersonMergeWith->HouseholdAsHead) { // Go through each of this's HouseholdParticipation -- Throw if it's another household, Delete if it's MergeWith's Household-as-Head foreach ($this->GetHouseholdParticipationArray() as $objHouseholdParticipation) { if ($objHouseholdParticipation->HouseholdId != $objPersonMergeWith->HouseholdAsHead->Id) { throw new QCallerException('Cannot merge MergeWith head of household with this person record which exists in other households'); } else { $objHouseholdParticipation->Delete(); } } $objHousehold->HeadPerson = $this; $objHousehold->Save(); $objParticipation = HouseholdParticipation::LoadByPersonIdHouseholdId($objPersonMergeWith->Id, $objHousehold->Id); $objParticipation->PersonId = $this->Id; $objParticipation->Save(); } else { // Otherwise: members of multiple households! but head of none foreach ($objPersonMergeWith->GetHouseholdParticipationArray() as $objHouseholdParticipation) { if (HouseholdParticipation::LoadByPersonIdHouseholdId($this->Id, $objHouseholdParticipation->HouseholdId)) { $objHouseholdParticipation->Delete(); } else { $objHouseholdParticipation->PersonId = $this->Id; $objHouseholdParticipation->Save(); } } } } } if (!$blnUseThisDetails) { $this->FirstName = $objPersonMergeWith->FirstName; $this->MiddleName = $objPersonMergeWith->MiddleName; $this->LastName = $objPersonMergeWith->LastName; $this->MailingLabel = $objPersonMergeWith->MailingLabel; $this->PriorLastNames = $objPersonMergeWith->PriorLastNames; $this->Nickname = $objPersonMergeWith->Nickname; $this->Title = $objPersonMergeWith->Title; $this->Suffix = $objPersonMergeWith->Suffix; $this->Gender = $objPersonMergeWith->Gender; $this->DateOfBirth = $objPersonMergeWith->DateOfBirth; $this->DobYearApproximateFlag = $objPersonMergeWith->DobYearApproximateFlag; $this->DobGuessedFlag = $objPersonMergeWith->DobGuessedFlag; $this->Age = $objPersonMergeWith->Age; $this->DeceasedFlag = $objPersonMergeWith->DeceasedFlag; $this->DateDeceased = $objPersonMergeWith->DateDeceased; } // Attributes foreach ($objPersonMergeWith->GetAttributeValueArray() as $objAttributeValue) { // Check for double-defined attributes if ($objDoubleDefinedAttribute = AttributeValue::LoadByAttributeIdPersonId($objAttributeValue->AttributeId, $this->Id)) { if ($blnUseThisDetails) { $objAttributeValue->Delete(); } else { $objDoubleDefinedAttribute->Delete(); $objAttributeValue->PersonId = $this->Id; $objAttributeValue->Save(); } // Nothing double-defined -- just move it over! } else { $objAttributeValue->PersonId = $this->Id; $objAttributeValue->Save(); } } // Comments foreach ($objPersonMergeWith->GetCommentArray() as $objComment) { $objComment->PersonId = $this->Id; $objComment->Save(); } // Memberships foreach ($objPersonMergeWith->GetMembershipArray() as $objMembership) { $objMembership->PersonId = $this->Id; $objMembership->Save(); } // Communication Lists foreach ($objPersonMergeWith->GetCommunicationListArray() as $objCommList) { $objPersonMergeWith->UnassociateCommunicationList($objCommList); if (!$this->IsCommunicationListAssociated($objCommList)) { $this->AssociateCommunicationList($objCommList); } } // Head Shots foreach ($objPersonMergeWith->GetHeadShotArray() as $objHeadShot) { $objHeadShot->PersonId = $this->Id; $objHeadShot->Save(); } // Group Participation foreach ($objPersonMergeWith->GetGroupParticipationArray() as $objGroupParticipation) { $objGroupParticipation->PersonId = $this->Id; $objGroupParticipation->Save(); } // NameItemAssn $objPersonMergeWith->UnassociateAllNameItems(); // Marrriage Records foreach ($objPersonMergeWith->GetMarriageArray() as $objMarriage) { $this->CreateMarriageWith($objMarriage->MarriedToPerson, $objMarriage->DateStart, $objMarriage->DateEnd, $objMarriage->MarriageStatusTypeId); $objMarriage->DeleteThisAndLinked(); } foreach ($objPersonMergeWith->GetMarriageAsMarriedToArray() as $objMarriage) { $this->CreateMarriageWith($objMarriage->Person, $objMarriage->DateStart, $objMarriage->DateEnd, $objMarriage->MarriageStatusTypeId); $objMarriage->DeleteThisAndLinked(); } // Family Relationships foreach ($objPersonMergeWith->GetRelationshipArray() as $objRelationship) { if (!Relationship::LoadByPersonIdRelatedToPersonId($this->Id, $objRelationship->RelatedToPersonId)) { $this->AddRelationship($objRelationship->RelatedToPerson, $objRelationship->RelationshipTypeId); } $objRelationship->DeleteThisAndLinked(); } foreach ($objPersonMergeWith->GetRelationshipAsRelatedToArray() as $objRelationship) { if (!Relationship::LoadByPersonIdRelatedToPersonId($this->Id, $objRelationship->PersonId)) { $this->AddRelationship($objRelationship->Person, $objRelationship->RelationshipTypeId); } $objRelationship->DeleteThisAndLinked(); } // Phones foreach ($objPersonMergeWith->GetPhoneArray() as $objContact) { $objContact->PersonId = $this->Id; $objContact->Save(); } // Addresses foreach ($objPersonMergeWith->GetAddressArray() as $objContact) { $objContact->PersonId = $this->Id; $objContact->Save(); } // Email foreach ($objPersonMergeWith->GetEmailArray() as $objContact) { $objContact->PersonId = $this->Id; $objContact->Save(); } // Other Contact Info foreach ($objPersonMergeWith->GetOtherContactInfoArray() as $objContact) { $objContact->PersonId = $this->Id; $objContact->Save(); } // Checking Account Lookups foreach ($objPersonMergeWith->GetCheckingAccountLookupArray() as $objCheckingAccount) { $objPersonMergeWith->UnassociateCheckingAccountLookup($objCheckingAccount); if (!$this->IsCheckingAccountLookupAssociated($objCheckingAccount)) { $this->AssociateCheckingAccountLookup($objCheckingAccount); } } // Stewardship Contributions foreach ($objPersonMergeWith->GetStewardshipContributionArray() as $objStewardship) { $objStewardship->PersonId = $this->Id; $objStewardship->Save(); } // Stewardship Pledges foreach ($objPersonMergeWith->GetStewardshipPledgeArray() as $objPledge) { // Check for double-defined pledge if ($objDoubleDefinedPledge = StewardshipPledge::LoadByPersonIdStewardshipFundId($this->Id, $objPledge->StewardshipFundId)) { if ($blnUseThisDetails) { $objPledge->Delete(); } else { $objDoubleDefinedPledge->Delete(); $objPledge->PersonId = $this->Id; $objPledge->Save(); } // Nope, just move it over like normal } else { $objPledge->PersonId = $this->Id; $objPledge->Save(); } } // Online Donations foreach ($objPersonMergeWith->GetOnlineDonationArray() as $objOnlineDonation) { $objOnlineDonation->PersonId = $this->Id; $objOnlineDonation->Save(); } // Public Login if ($objPublicLogin = $objPersonMergeWith->PublicLogin) { $objPublicLogin->PersonId = $this->Id; $objPublicLogin->Save(); } // Events and Classes foreach ($objPersonMergeWith->GetSignupEntryArray() as $objSignupEntry) { $objSignupEntry->PersonId = $this->Id; $objSignupEntry->Save(); } foreach ($objPersonMergeWith->GetSignupEntryAsSignupByArray() as $objSignupEntry) { $objSignupEntry->SignupByPersonId = $this->Id; $objSignupEntry->Save(); } foreach ($objPersonMergeWith->GetClassRegistrationArray() as $objClassRegistration) { $objClassRegistration->PersonId = $this->Id; $objClassRegistration->Save(); } // Stewardship Post Line Items foreach ($objPersonMergeWith->GetStewardshipPostLineItemArray() as $objStewardship) { $objStewardship->PersonId = $this->Id; $objStewardship->Save(); } // Email Message Route foreach ($objPersonMergeWith->GetEmailMessageRouteArray() as $objEmailMessageRoute) { $objEmailMessageRoute->PersonId = $this->Id; $objEmailMessageRoute->Save(); } // Search Query foreach ($objPersonMergeWith->GetSearchQueryArray() as $objSearchQuery) { $objSearchQuery->PersonId = $this->Id; $objSearchQuery->Save(); } // Final Refresh/Cleanup $this->RefreshAge(false); $this->RefreshMaritalStatusTypeId(false); $this->RefreshMembershipStatusTypeId(false); $this->RefreshPrimaryContactInfo(false); $this->Save(); $this->RefreshNameItemAssociations(); $objPersonMergeWith->Delete(); Person::GetDatabase()->TransactionCommit(); }
protected function btnSave_Click($strFormId, $strControlId, $strParameter) { $this->dlgMessage->RemoveAllButtons(); $radSelected = null; foreach ($this->radSelectArray as $radSelect) { if ($radSelect->Checked) { if ($radSelected) { $this->dlgMessage->MessageHtml = 'You cannot remove more than one person at a time.'; $this->dlgMessage->ShowDialogBox(); return; } $radSelected = $radSelect; } } if (!$radSelected) { $this->dlgMessage->MessageHtml = 'You must select a person to remove.'; $this->dlgMessage->ShowDialogBox(); return; } $objParticipation = HouseholdParticipation::Load($radSelected->ActionParameter); if ($objParticipation->HouseholdId != $this->objHousehold->Id) { $this->dlgMessage->MessageHtml = 'Participation record not for this household.'; $this->dlgMessage->ShowDialogBox(); return; } $this->objPersonToRemove = $objParticipation->Person; switch ($this->objPersonToRemove->GetHouseholdStatus()) { case Person::HouseholdStatusMemberOfOne: $this->dlgMessage->MessageHtml = sprintf('<strong>%s</strong> does not belong to any other household records. Make %s an individual with no household records, or delete %s record altogether?', QApplication::HtmlEntities($this->objPersonToRemove->Name), $this->objPersonToRemove->PronounIndirectObject, $this->objPersonToRemove->PronounAdjective); $this->dlgMessage->AddButton('Make Individual', MessageDialog::ButtonPrimary, 'RemoveFromHousehold'); $this->dlgMessage->AddButton('Delete Record', MessageDialog::ButtonPrimary, 'DeletePerson'); $this->dlgMessage->AddButton('Cancel', MessageDialog::ButtonSecondary, 'HideDialogBox', $this->dlgMessage); break; case Person::HouseholdStatusMemberOfMultiple: if ($this->objPersonToRemove->CountHouseholdParticipations() == 2) { $this->dlgMessage->MessageHtml = '<strong>%s</strong> belongs to another household. After removing %s from the %s, %s will still be a member of the other household.'; } else { $this->dlgMessage->MessageHtml = '<strong>%s</strong> belongs to other households. After removing %s from the %s, %s will still be a member of these other households.'; } $this->dlgMessage->MessageHtml = sprintf($this->dlgMessage->MessageHtml, QApplication::HtmlEntities($this->objPersonToRemove->Name), $this->objPersonToRemove->PronounIndirectObject, QApplication::HtmlEntities($this->objHousehold->Name), $this->objPersonToRemove->PronounSubject); $this->dlgMessage->AddButton('Okay', MessageDialog::ButtonPrimary, 'RemoveFromHousehold'); $this->dlgMessage->AddButton('Cancel', MessageDialog::ButtonSecondary, 'HideDialogBox', $this->dlgMessage); break; case Person::HouseholdStatusNone: case Person::HouseholdStatusHeadOfOne: case Person::HouseholdStatusHeadOfFamily: case Person::HouseholdStatusError: default: $this->dlgMessage->MessageHtml = sprintf('An unknown data error occurred while trying to remove <strong>%s</strong> from this "%s" household. Please contact a ChMS Administrator to report the issue.', QApplication::HtmlEntities($this->objPersonToRemove->Name), QApplication::HtmlEntities($this->objHousehold->Name)); break; } $this->dlgMessage->ShowDialogBox(); }
QApplication::Authenticate(null, array(PermissionType::AccessStewardship)); // Setup Zend Framework load set_include_path(get_include_path() . ':' . __INCLUDES__); require_once 'Zend/Loader.php'; Zend_Loader::loadClass('Zend_Pdf'); // Expected PathInfo to be PersonId/HouseholdId/Year // Note that HouseholdId is OPTIONAL -- if HouseholdId, then it is a combined statement for the entire household // Otherwise, if no HouseholdId (e.g. "0"), then it is just a individual statement $objPerson = Person::Load(QApplication::PathInfo(0)); $objObject = $objPerson; if (QApplication::PathInfo(1)) { $objHousehold = Household::Load(QApplication::PathInfo(1)); if (!$objHousehold) { QApplication::Redirect('/main/'); } if (!HouseholdParticipation::LoadByPersonIdHouseholdId($objPerson->Id, $objHousehold->Id)) { QApplication::Redirect('/main/'); } $objObject = $objHousehold; } if (!(QApplication::PathInfo(2) >= 1950 && QApplication::PathInfo(2) <= 2500)) { QApplication::Redirect('/main/'); } // Create the PDF Object $objPdf = new Zend_Pdf(); StewardshipContribution::GenerateReceiptInPdf($objPdf, $objObject, QApplication::PathInfo(2), true); // Get PDF document as a string $strData = $objPdf->render(); // Disable strict no-cache for IE due to IE issues with downloading no-cache items if (QApplication::IsBrowser(QBrowserType::InternetExplorer)) { header("Pragma:");
/** * This will set this phone object as the "primary" phone number for (if associated to an address) the address * or (if associated to a person) the person. * * Alternatively, if the phone is associated with the address (e.g. a home phone), you can explicitly * pass in a Person in that house to set as "primary" for that person. * * This will automatically UNSET as primary any current-primary phone (if applicable) * @return void */ public function SetAsPrimary(Person $objPerson = null, Address $objAddress = null) { if ($objPerson) { if ($this->PersonId != $objPerson->Id && (!$this->Address || !$this->Address->Household || !HouseholdParticipation::LoadByPersonIdHouseholdId($objPerson->Id, $this->Address->HouseholdId))) { throw new QCallerException('Cannot set as primary phone for person not in the household for this address'); } $objPerson->PrimaryPhone = $this; $objPerson->Save(); $objPerson->RefreshPrimaryContactInfo(); } else { if ($objAddress) { if ($objAddress->Id != $this->intAddressId) { throw new QCallerException('Cannot set as primary phone for home address that does not own this phone object'); } $objAddress->PrimaryPhone = $this; $objAddress->Save(); } else { if ($this->Address) { $this->Address->PrimaryPhone = $this; $this->Address->Save(); } else { $this->Person->PrimaryPhone = $this; $this->Person->Save(); $this->Person->RefreshPrimaryContactInfo(); } } } }
protected function btnNext_Click($strFormId, $strControlId, $strParameter) { // Get Participation Records $this->objSelectedPersonArray = array(); foreach ($this->chkSelectArray as $chkSelect) { if ($chkSelect->Checked) { $objParticipation = HouseholdParticipation::Load($chkSelect->ActionParameter); if ($objParticipation->HouseholdId != $this->objHousehold->Id) { throw new Exception('Invalid Participation Selected'); } $this->objSelectedPersonArray[] = $objParticipation->Person; } } if (!count($this->objSelectedPersonArray)) { $this->dlgMessage->RemoveAllButtons(); $this->dlgMessage->MessageHtml = 'You must select at least one person.'; $this->dlgMessage->ShowDialogBox(); return; } else { $strNameArray = array(); foreach ($this->objSelectedPersonArray as $objPerson) { $strNameArray[] = $objPerson->FirstName; } $this->lblHeadline->Text = 'Selected: ' . implode(', ', $strNameArray); $this->dtgMembers->Visible = false; $this->lstHead->Visible = true; $this->pnlAddress->Visible = true; $this->pnlAddress->objDelegate = new EditHomeAddressDelegate($this->pnlAddress, null, null, false); // Since this HomeAddress panel/delegate is really for a NEW household's address, we want to set it to null $this->pnlAddress->objDelegate->mctAddress->Address->Household = null; $this->btnNext->Visible = false; $this->btnSave->Visible = true; $this->lstHead->RemoveAllItems(); foreach ($this->objSelectedPersonArray as $objPerson) { $this->lstHead->AddItem($objPerson->Name, $objPerson->Id); } $this->lstHead->SelectedIndex = 0; } }
/** * Main utility method to aid with data binding. It is used by the default BindAllRows() databinder but * could and should be used by any custom databind methods that would be used for instances of this * MetaDataGrid, by simply passing in a custom QQCondition and/or QQClause. * * If a paginator is set on this DataBinder, it will use it. If not, then no pagination will be used. * It will also perform any sorting (if applicable). * * @param QQCondition $objConditions override the default condition of QQ::All() to the query, itself * @param QQClause[] $objOptionalClauses additional optional QQClause object or array of QQClause objects for the query * @return void */ public function MetaDataBinder(QQCondition $objCondition = null, $objOptionalClauses = null) { // Setup input parameters to default values if none passed in if (!$objCondition) { $objCondition = QQ::All(); } $objClauses = $objOptionalClauses ? $objOptionalClauses : array(); // We need to first set the TotalItemCount, which will affect the calcuation of LimitClause below if ($this->Paginator) { $this->TotalItemCount = HouseholdParticipation::QueryCount($objCondition, $objClauses); } // If a column is selected to be sorted, and if that column has a OrderByClause set on it, then let's add // the OrderByClause to the $objClauses array if ($objClause = $this->OrderByClause) { array_push($objClauses, $objClause); } // Add the LimitClause information, as well if ($objClause = $this->LimitClause) { array_push($objClauses, $objClause); } // Set the DataSource to be a Query result from HouseholdParticipation, given the clauses above $this->DataSource = HouseholdParticipation::QueryArray($objCondition, $objClauses); }