/**
  * 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');
     }
 }
 /**
  * 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);
 }
 /**
  * Load an array of StewardshipPledge objects,
  * by StewardshipFundId Index(es)
  * @param integer $intStewardshipFundId
  * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  * @return StewardshipPledge[]
  */
 public static function LoadArrayByStewardshipFundId($intStewardshipFundId, $objOptionalClauses = null)
 {
     // Call StewardshipPledge::QueryArray to perform the LoadArrayByStewardshipFundId query
     try {
         return StewardshipPledge::QueryArray(QQ::Equal(QQN::StewardshipPledge()->StewardshipFundId, $intStewardshipFundId), $objOptionalClauses);
     } catch (QCallerException $objExc) {
         $objExc->IncrementOffset();
         throw $objExc;
     }
 }