Esempio n. 1
0
 /**
  * Refreshes pledge infromation (e.g. amount contributed, status, etc.)
  * @param boolean $blnSave whether or not to save
  */
 public function Refresh($blnSave = true)
 {
     $objAmountArray = StewardshipContributionAmount::QueryArray(QQ::AndCondition(QQ::Equal(QQN::StewardshipContributionAmount()->StewardshipFundId, $this->StewardshipFundId), QQ::Equal(QQN::StewardshipContributionAmount()->StewardshipContribution->PersonId, $this->PersonId)));
     $fltTotal = 0;
     foreach ($objAmountArray as $objAmount) {
         $fltTotal += $objAmount->Amount;
     }
     $this->fltContributedAmount = $fltTotal;
     $this->fltRemainingAmount = max(0, $this->fltPledgeAmount - $this->fltContributedAmount);
     $this->blnFulfilledFlag = $this->fltRemainingAmount < 1.0;
     if ($this->blnFulfilledFlag) {
         $this->blnActiveFlag = false;
     }
     if ($blnSave) {
         $this->Save();
     }
 }
 /**
  * Count StewardshipContributionAmounts
  * by StewardshipFundId Index(es)
  * @param integer $intStewardshipFundId
  * @return int
  */
 public static function CountByStewardshipFundId($intStewardshipFundId, $objOptionalClauses = null)
 {
     // Call StewardshipContributionAmount::QueryCount to perform the CountByStewardshipFundId query
     return StewardshipContributionAmount::QueryCount(QQ::Equal(QQN::StewardshipContributionAmount()->StewardshipFundId, $intStewardshipFundId), $objOptionalClauses);
 }
 protected function SetupPanel()
 {
     // /stewardship/batch.php/950#1/edit_contribution/UrlHash/UrlHash2/UrlHash3
     // 950 = BatchId
     // #1 = StackNumber
     // UrlHash can be "New" for new manual entry, an Id # for a ContributionId, or 0 for "Check" entyr
     // UrlHash2 must be the check hash (if applicable)
     // Urlhash3 is a PersonId to automagically select
     $this->blnScanFlag = false;
     // Creating New?
     if ($this->strUrlHashArgument == 'new') {
         // Creating New... Again?
         if ($this->strUrlHashArgument2 == 'again') {
             return $this->ReturnTo(sprintf('#%s/edit_contribution/new', $this->objStack->StackNumber));
         }
         $objContribution = new StewardshipContribution();
         $objContribution->StewardshipBatch = $this->objBatch;
         $objContribution->StewardshipStack = $this->objStack;
         $objContribution->DateEntered = QDateTime::Now();
         $objContribution->CreatedByLogin = QApplication::$Login;
         $objContribution->UnpostedFlag = true;
         $objContribution->DateCredited = new QDateTime($this->objBatch->DateCredited);
         $objContribution->StewardshipContributionTypeId = StewardshipContributionType::Cash;
         // Editing an existing
     } else {
         if ($this->strUrlHashArgument) {
             $objContribution = StewardshipContribution::Load($this->strUrlHashArgument);
             if (!$objContribution || $objContribution->StewardshipStackId != $this->objStack->Id || $objContribution->StewardshipBatchId != $this->objBatch->Id) {
                 $this->ReturnTo('#' . $this->objStack->StackNumber);
             }
             // Scanning?
         } else {
             if ($this->strUrlHashArgument2) {
                 $objContribution = StewardshipContribution::CreateFromCheckImage(QApplication::$Login, $this->objStack, $this->strUrlHashArgument2);
                 $this->blnScanFlag = true;
                 $this->imgCheckImage = new TiffImageControl($this);
                 $this->imgCheckImage->ImagePath = $objContribution->TempPath;
                 $this->imgCheckImage->Width = '390';
                 // Error -- go back
             } else {
                 $this->ReturnTo('#' . $this->objStack->StackNumber);
             }
         }
     }
     // Auto-set a new person (if specified)
     if ($objPerson = Person::Load($this->strUrlHashArgument3)) {
         $objContribution->Person = $objPerson;
     }
     // Setup Fields
     $this->mctContribution = new StewardshipContributionMetaControl($this, $objContribution);
     $this->chkNonDeductibleFlag = $this->mctContribution->chkNonDeductibleFlag_Create();
     $this->chkNonDeductibleFlag->Name = 'Non-Deductibile?';
     $this->chkNonDeductibleFlag->Text = 'Check if contribution is <strong>NOT</strong> deductible';
     $this->chkNonDeductibleFlag->HtmlEntities = false;
     if (!$this->blnScanFlag) {
         $this->lstStewardshipContributionType = $this->mctContribution->lstStewardshipContributionType_Create();
         $this->lstStewardshipContributionType->AddAction(new QChangeEvent(), new QAjaxControlAction($this, 'lstStewardshipContributionType_Change'));
         $this->txtAuthorization = $this->mctContribution->txtAuthorizationNumber_Create();
         $this->txtCheckNumber = $this->mctContribution->txtCheckNumber_Create();
         $this->txtCheckNumber->AddAction(new QEnterKeyEvent(), new QTerminateAction());
         $this->txtAlternateSource = $this->mctContribution->txtAlternateSource_Create();
         $this->lstStewardshipContributionType_Change();
     } else {
         // If we're scanning, then make sure we allow selecti onof Check or ReturnedCheck
         $this->lstStewardshipContributionType = $this->mctContribution->lstStewardshipContributionType_Create();
         $intIndex = 0;
         while ($intIndex < count($this->lstStewardshipContributionType->GetAllItems())) {
             $objListItem = $this->lstStewardshipContributionType->GetItem($intIndex);
             if ($objListItem->Value == StewardshipContributionType::Check || $objListItem->Value == StewardshipContributionType::ReturnedCheck) {
                 $intIndex++;
             } else {
                 $this->lstStewardshipContributionType->RemoveItem($intIndex);
             }
         }
         $this->txtCheckNumber = $this->mctContribution->txtCheckNumber_Create();
         $this->txtCheckNumber->AddAction(new QEnterKeyEvent(), new QTerminateAction());
         $this->txtCheckNumber->Select();
     }
     // Setup Total Amount
     $this->lblTotalAmount = new QLabel($this);
     $this->lblTotalAmount->HtmlEntities = false;
     // Setup Error Panels
     $this->pnlFundingError = new QPanel($this);
     $this->pnlFundingError->Visible = false;
     $this->pnlFundingError->CssClass = 'errorMessage';
     $this->pnlPersonError = new QPanel($this);
     $this->pnlPersonError->Visible = false;
     $this->pnlPersonError->CssClass = 'errorMessage';
     // Setup AmountArray
     $this->mctAmountArray = array();
     $objAmountArray = $this->mctContribution->StewardshipContribution->GetStewardshipContributionAmountArray(QQ::OrderBy(QQN::StewardshipContributionAmount()->Id));
     for ($i = 0; $i < 5; $i++) {
         if (array_key_exists($i, $objAmountArray)) {
             $objAmount = $objAmountArray[$i];
         } else {
             $objAmount = new StewardshipContributionAmount();
         }
         $mctAmount = new StewardshipContributionAmountMetaControl($this, $objAmount);
         $this->mctAmountArray[] = $mctAmount;
         if ($mctAmount->EditMode) {
             $lstFund = $mctAmount->lstStewardshipFund_Create(null, QQ::All(), QQ::OrderBy(QQN::StewardshipFund()->Name));
         } else {
             $lstFund = $mctAmount->lstStewardshipFund_Create(null, QQ::Equal(QQN::StewardshipFund()->ActiveFlag, true), QQ::OrderBy(QQN::StewardshipFund()->Name));
         }
         $lstFund->Required = false;
         $lstFund->ActionParameter = $i;
         $txtAmount = $mctAmount->txtAmount_Create();
         $txtAmount->ActionParameter = $i;
         $txtAmount->Text = sprintf('%.2f', $txtAmount->Text, 2);
         $lstFund->AddAction(new QChangeEvent(), new QAjaxControlAction($this, 'lstFund_Change'));
         $this->lstFund_Change(null, null, $i);
         $txtAmount->AddAction(new QChangeEvent(), new QAjaxControlAction($this, 'lblTotalAmount_Refresh'));
         $txtAmount->AddAction(new QEnterKeyEvent(), new QAjaxControlAction($this, 'txtAmount_Enter'));
         $txtAmount->AddAction(new QEnterKeyEvent(), new QTerminateAction());
         $this->lblTotalAmount_Refresh(null, null, null);
     }
     // Setup ChangePerson Dialog stuff
     $this->dlgChangePerson = new StewardshipSelectPersonDialogBox($this, null, $objContribution, $this, 'dlgChangePerson_Select');
     $this->btnChangePerson = new QButton($this);
     $this->btnChangePerson->Text = 'Change';
     $this->btnChangePerson->CssClass = 'primary';
     $this->btnChangePerson->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnChangePerson_Click'));
     if ($this->blnScanFlag) {
         $this->ProcessNewCheck();
         $this->btnSaveAndScanAgain = new QButton($this);
         $this->btnSaveAndScanAgain->CausesValidation = true;
         $this->btnSaveAndScanAgain->Text = 'Save and Scan Next Check';
         $this->btnSaveAndScanAgain->CssClass = 'primary';
         $this->btnSaveAndScanAgain->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnSave_Click'));
     } else {
         if (!$this->mctContribution->EditMode) {
             if (!$this->mctContribution->StewardshipContribution->Person) {
                 $this->btnChangePerson_Click(null, null, null);
                 $this->dlgChangePerson->dtgPeople->NoDataHtml = '<div class="section sectionBatchInfo"><strong>Search For Individual</strong><br/><br/>' . 'Use above fields to find the individual for this new entry.</div>';
             } else {
                 $this->mctAmountArray[0]->StewardshipFundIdControl->Focus();
             }
             $this->btnSaveAndScanAgain = new QButton($this);
             $this->btnSaveAndScanAgain->CausesValidation = true;
             $this->btnSaveAndScanAgain->Text = 'Save and Enter Next Entry';
             $this->btnSaveAndScanAgain->ActionParameter = 'new';
             $this->btnSaveAndScanAgain->CssClass = 'primary';
             $this->btnSaveAndScanAgain->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnSave_Click'));
         }
     }
     if (!$this->mctContribution->EditMode) {
         $this->LoadSelectedFundsFromSession();
     } else {
         $this->btnSave->Text = 'Update';
     }
 }
 /**
  * Used internally by the Meta-based Add Column tools.
  *
  * Given a QQNode or a Text String, this will return a StewardshipContributionAmount-based QQNode.
  * It will also verify that it is a proper StewardshipContributionAmount-based QQNode, and will throw an exception otherwise.
  *
  * @param mixed $mixContent
  * @return QQNode
  */
 protected function ResolveContentItem($mixContent)
 {
     if ($mixContent instanceof QQNode) {
         if (!$mixContent->_ParentNode) {
             throw new QCallerException('Content QQNode cannot be a Top Level Node');
         }
         if ($mixContent->_RootTableName == 'stewardship_contribution_amount') {
             if ($mixContent instanceof QQReverseReferenceNode && !$mixContent->_PropertyName) {
                 throw new QCallerException('Content QQNode cannot go through any "To Many" association nodes.');
             }
             $objCurrentNode = $mixContent;
             while ($objCurrentNode = $objCurrentNode->_ParentNode) {
                 if (!$objCurrentNode instanceof QQNode) {
                     throw new QCallerException('Content QQNode cannot go through any "To Many" association nodes.');
                 }
                 if ($objCurrentNode instanceof QQReverseReferenceNode && !$objCurrentNode->_PropertyName) {
                     throw new QCallerException('Content QQNode cannot go through any "To Many" association nodes.');
                 }
             }
             return $mixContent;
         } else {
             throw new QCallerException('Content QQNode has a root table of "' . $mixContent->_RootTableName . '". Must be a root of "stewardship_contribution_amount".');
         }
     } else {
         if (is_string($mixContent)) {
             switch ($mixContent) {
                 case 'Id':
                     return QQN::StewardshipContributionAmount()->Id;
                 case 'StewardshipContributionId':
                     return QQN::StewardshipContributionAmount()->StewardshipContributionId;
                 case 'StewardshipContribution':
                     return QQN::StewardshipContributionAmount()->StewardshipContribution;
                 case 'StewardshipFundId':
                     return QQN::StewardshipContributionAmount()->StewardshipFundId;
                 case 'StewardshipFund':
                     return QQN::StewardshipContributionAmount()->StewardshipFund;
                 case 'Amount':
                     return QQN::StewardshipContributionAmount()->Amount;
                 default:
                     throw new QCallerException('Simple Property not found in StewardshipContributionAmountDataGrid content: ' . $mixContent);
             }
         } else {
             if ($mixContent instanceof QQAssociationNode) {
                 throw new QCallerException('Content QQNode cannot go through any "To Many" association nodes.');
             } else {
                 throw new QCallerException('Invalid Content type');
             }
         }
     }
 }
 /**
  * @param integer[] $intPersonIdArray
  * @param integer $intYear
  * @param integer $intQuarter optional, can be 1, 2 or 3 to limit results to JUST Q1, Q1-Q2, Q1-Q3 data if applicable
  * @return StewardshipContributionAmount[]
  */
 public static function GetContributionAmountArrayForPersonArray($intPersonIdArray, $intYear, $intQuarter = null)
 {
     switch ($intQuarter) {
         case 1:
             $strEndMonthDay = '-03-31 23:59:59';
             break;
         case 2:
             $strEndMonthDay = '-06-30 23:59:59';
             break;
         case 3:
             $strEndMonthDay = '-09-30 23:59:59';
             break;
         default:
             $strEndMonthDay = '-12-31 23:59:59';
             break;
     }
     $objCondition = QQ::AndCondition(QQ::In(QQN::StewardshipContributionAmount()->StewardshipContribution->PersonId, $intPersonIdArray), QQ::GreaterOrEqual(QQN::StewardshipContributionAmount()->StewardshipContribution->DateCredited, new QDateTime($intYear . '-01-01 00:00:00')), QQ::LessOrEqual(QQN::StewardshipContributionAmount()->StewardshipContribution->DateCredited, new QDateTime($intYear . $strEndMonthDay)));
     return StewardshipContributionAmount::QueryArray($objCondition, QQ::OrderBy(QQN::StewardshipContributionAmount()->StewardshipContribution->DateCredited, QQN::StewardshipContributionAmount()->Id));
 }
Esempio n. 6
0
 public function dtgStewardshipContributionAmount_Bind()
 {
     $this->fltTotal = 0;
     if ($this->chkCombined && $this->chkCombined->Checked) {
         $intPersonIdArray = array();
         foreach ($this->objForm->objHousehold->GetHouseholdParticipationArray() as $objParticipation) {
             $intPersonIdArray[] = $objParticipation->PersonId;
         }
         $objCondition = QQ::In(QQN::StewardshipContributionAmount()->StewardshipContribution->PersonId, $intPersonIdArray);
     } else {
         $objCondition = QQ::Equal(QQN::StewardshipContributionAmount()->StewardshipContribution->PersonId, $this->objPerson->Id);
     }
     if ($this->lstYear->SelectedValue) {
         $objCondition = QQ::AndCondition($objCondition, QQ::GreaterOrEqual(QQN::StewardshipContributionAmount()->StewardshipContribution->DateCredited, new QDateTime($this->lstYear->SelectedValue . '-01-01 00:00:00')), QQ::LessOrEqual(QQN::StewardshipContributionAmount()->StewardshipContribution->DateCredited, new QDateTime($this->lstYear->SelectedValue . '-12-31 23:59:59')));
     }
     if ($this->lstFund->SelectedValue) {
         $objCondition = QQ::AndCondition($objCondition, QQ::Equal(QQN::StewardshipContributionAmount()->StewardshipFundId, $this->lstFund->SelectedValue));
     }
     $this->dtgStewardshipContributionAmount->MetaDataBinder($objCondition);
     // Add 'Totals' Row
     $objDataSource = $this->dtgStewardshipContributionAmount->DataSource;
     $objDataSource[] = new StewardshipContributionAmount();
     $this->dtgStewardshipContributionAmount->DataSource = $objDataSource;
 }
Esempio n. 7
0
 public function dtgLineItems_Unposted_Bind()
 {
     $this->dtgLineItems->DataSource = StewardshipContributionAmount::QueryArray(QQ::AndCondition(QQ::Equal(QQN::StewardshipContributionAmount()->StewardshipContribution->UnpostedFlag, true), QQ::Equal(QQN::StewardshipContributionAmount()->StewardshipContribution->StewardshipBatchId, $this->objBatch->Id)), QQ::OrderBy(QQN::StewardshipContributionAmount()->StewardshipContribution->Person->LastName, QQN::StewardshipContributionAmount()->StewardshipContribution->Person->FirstName));
 }