コード例 #1
0
ファイル: index.php プロジェクト: alcf/chms
 public function pxyActiveFlagToggle_Click($strFormId, $strControlId, $strParameter)
 {
     $objPledge = StewardshipPledge::Load($strParameter);
     $objPledge->ActiveFlag = false;
     $objPledge->Save();
     $this->dtgPledges->Refresh();
 }
コード例 #2
0
ファイル: Person.class.php プロジェクト: alcf/chms
 /**
  * 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();
 }
コード例 #3
0
ファイル: PersonGen.class.php プロジェクト: alcf/chms
    /**
     * Deletes all associated StewardshipPledges
     * @return void
     */
    public function DeleteAllStewardshipPledges()
    {
        if (is_null($this->intId)) {
            throw new QUndefinedPrimaryKeyException('Unable to call UnassociateStewardshipPledge on this unsaved Person.');
        }
        // Get the Database Object for this Class
        $objDatabase = Person::GetDatabase();
        // Journaling
        if ($objDatabase->JournalingDatabase) {
            foreach (StewardshipPledge::LoadArrayByPersonId($this->intId) as $objStewardshipPledge) {
                $objStewardshipPledge->Journal('DELETE');
            }
        }
        // Perform the SQL Query
        $objDatabase->NonQuery('
				DELETE FROM
					`stewardship_pledge`
				WHERE
					`person_id` = ' . $objDatabase->SqlVariable($this->intId) . '
			');
    }
コード例 #4
0
ファイル: post-acs-cleanup.cli.php プロジェクト: alcf/chms
    $objHousehold->Save();
}
QDataGen::DisplayForEachTaskEnd('Refreshing Household data');
$objStewardshipCursor = StewardshipContribution::QueryCursor(QQ::All());
QDataGEn::DisplayForEachTaskStart('Refreshing Contributions', StewardshipContribution::CountAll());
while ($objContribution = StewardshipContribution::InstantiateCursor($objStewardshipCursor)) {
    QDataGen::DisplayForEachTaskNext('Refreshing Contributions');
    $objContribution->RefreshTotalAmount();
}
QDataGen::DisplayForEachTaskEnd('Refreshing Contributions');
$objStewardshipCursor = StewardshipStack::QueryCursor(QQ::All());
QDataGEn::DisplayForEachTaskStart('Refreshing Stacks', StewardshipStack::CountAll());
while ($objStack = StewardshipStack::InstantiateCursor($objStewardshipCursor)) {
    QDataGen::DisplayForEachTaskNext('Refreshing Stacks');
    $objStack->RefreshActualTotalAmount();
}
QDataGen::DisplayForEachTaskEnd('Refreshing Stacks');
$objStewardshipCursor = StewardshipBatch::QueryCursor(QQ::All());
QDataGEn::DisplayForEachTaskStart('Refreshing Batches', StewardshipBatch::CountAll());
while ($objBatch = StewardshipBatch::InstantiateCursor($objStewardshipCursor)) {
    QDataGen::DisplayForEachTaskNext('Refreshing Batches');
    $objBatch->PostBalance(Login::Load(1));
}
QDataGen::DisplayForEachTaskEnd('Refreshing Batches');
$objStewardshipCursor = StewardshipPledge::QueryCursor(QQ::All());
QDataGEn::DisplayForEachTaskStart('Refreshing Pledges', StewardshipPledge::CountAll());
while ($objPledge = StewardshipPledge::InstantiateCursor($objStewardshipCursor)) {
    QDataGen::DisplayForEachTaskNext('Refreshing Pledges');
    $objPledge->Refresh();
}
QDataGen::DisplayForEachTaskEnd('Refreshing Pledges');
コード例 #5
0
 /**
  * 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 StewardshipPledgeMetaControl
  * @param integer $intId primary key value
  * @param QMetaControlCreateType $intCreateType rules governing StewardshipPledge object creation - defaults to CreateOrEdit
  * @return StewardshipPledgeMetaControl
  */
 public static function Create($objParentObject, $intId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit)
 {
     // Attempt to Load from PK Arguments
     if (strlen($intId)) {
         $objStewardshipPledge = StewardshipPledge::Load($intId);
         // StewardshipPledge was found -- return it!
         if ($objStewardshipPledge) {
             return new StewardshipPledgeMetaControl($objParentObject, $objStewardshipPledge);
         } else {
             if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) {
                 throw new QCallerException('Could not find a StewardshipPledge 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 StewardshipPledgeMetaControl($objParentObject, new StewardshipPledge());
 }
コード例 #6
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 = StewardshipPledge::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 StewardshipPledge, given the clauses above
     $this->DataSource = StewardshipPledge::QueryArray($objCondition, $objClauses);
 }
コード例 #7
0
 /**
  * Given an existing Zend_Pdf record, this will generate the PDF Receipt page(s) for this Person or Household for the given year.
  * @param Zend_Pdf $objPdf
  * @param mixed $objPersonOrHousehold
  * @param integer $intYear
  * @param boolean $blnDrawLegal whether or not to include the "legal" tax information (e.g. yes for annual, no for quarterly)
  * @param integer $intQuarter optional, can be 1, 2 or 3 to limit results to JUST Q1, Q1-Q2, Q1-Q3 data if applicable
  */
 public static function GenerateReceiptInPdf(Zend_Pdf $objPdf, $objPersonOrHousehold, $intYear, $blnDrawLegal, $intQuarter = null)
 {
     $intPersonIdArray = self::GetPersonIdArrayForPersonOrHousehold($objPersonOrHousehold);
     // Get the Contributions
     $objContributionAmountArray = self::GetContributionAmountArrayForPersonArray($intPersonIdArray, $intYear, $intQuarter);
     // Get the Pledges
     $objCondition = QQ::AndCondition(QQ::In(QQN::StewardshipPledge()->PersonId, $intPersonIdArray), QQ::OrCondition(QQ::Equal(QQN::StewardshipPledge()->ActiveFlag, true), QQ::AndCondition(QQ::GreaterOrEqual(QQN::StewardshipPledge()->DateStarted, new QDateTime($intYear . '-01-01 00:00:00')), QQ::LessOrEqual(QQN::StewardshipPledge()->DateStarted, new QDateTime($intYear . '-12-31 23:59:59'))), QQ::AndCondition(QQ::GreaterOrEqual(QQN::StewardshipPledge()->DateEnded, new QDateTime($intYear . '-01-01 00:00:00')), QQ::LessOrEqual(QQN::StewardshipPledge()->DateEnded, new QDateTime($intYear . '-12-31 23:59:59'))), QQ::AndCondition(QQ::GreaterOrEqual(QQN::StewardshipPledge()->DateEnded, new QDateTime($intYear . '-12-31 23:59:59')), QQ::LessOrEqual(QQN::StewardshipPledge()->DateStarted, new QDateTime($intYear . '-01-01 00:00:00')))));
     $objPledgeArray = StewardshipPledge::QueryArray($objCondition, QQ::OrderBy(QQN::StewardshipPledge()->DateStarted, QQN::StewardshipPledge()->DateEnded));
     // New Page every 38
     $intPageNumber = 1;
     $objPageOneOfThis = null;
     $intTotalPages = floor((count($objContributionAmountArray) - 1) / 38) + 1;
     for ($intIndex = 0; $intIndex < count($objContributionAmountArray); $intIndex += 38) {
         $objPage = $objPdf->newPage(Zend_Pdf_Page::SIZE_LETTER);
         if (!$objPageOneOfThis) {
             $objPageOneOfThis = $objPage;
         }
         $objPdf->pages[] = $objPage;
         // Draw Header
         if ($intPageNumber == 1) {
             self::DrawHeader($objPage);
             self::DrawAddress($objPage, $objPersonOrHousehold);
             self::DrawFooter($objPage, $blnDrawLegal);
             self::DrawSummary($objPage, $objContributionAmountArray, $intYear);
             self::DrawPledges($objPage, $objPledgeArray);
         }
         // Draw Page Info
         $intY = $intPageNumber == 1 ? STEWARDSHIP_TOP - 1.7125 * 72 : STEWARDSHIP_TOP - 0.5 * 72;
         self::DrawInfo($objPage, $objPersonOrHousehold, $intYear, $intQuarter, $intY, $intPageNumber, $intTotalPages);
         // Draw Items
         $intY = $intPageNumber == 1 ? STEWARDSHIP_TOP - 3.5 * 72 : STEWARDSHIP_TOP - 1.5 * 72;
         self::DrawItems($objPage, array_slice($objContributionAmountArray, $intIndex, 38), $intY);
         // Draw Footer
         $intPageNumber++;
     }
     $blnNonDeductibleFound = false;
     foreach ($objContributionAmountArray as $objAmount) {
         if ($objAmount->StewardshipContribution->NonDeductibleFlag) {
             $blnNonDeductibleFound = true;
         }
     }
     if ($blnNonDeductibleFound) {
         $objPage = $objPageOneOfThis;
         $objPage->setFillColor(new Zend_Pdf_Color_GrayScale(0));
         $objPage->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 8);
         $objPage->drawText('(*) denotes a contribution that does not qualify for tax deduction.', 14, 149, 'UTF-8');
     }
 }
コード例 #8
0
 public static function GetSoapArrayFromArray($objArray)
 {
     if (!$objArray) {
         return null;
     }
     $objArrayToReturn = array();
     foreach ($objArray as $objObject) {
         array_push($objArrayToReturn, StewardshipPledge::GetSoapObjectFromObject($objObject, true));
     }
     return unserialize(serialize($objArrayToReturn));
 }