protected function Form_Create() { switch (QApplication::PathInfo(0)) { case 'funds': $this->dtgReport = new QDataGrid($this); $this->dtgReport->AddColumn(new QDataGridColumn('Fund', '<?= $_ITEM->StewardshipFund->Name; ?>', 'Width=300px')); $this->dtgReport->AddColumn(new QDataGridColumn('Account Number', '<?= $_ITEM->StewardshipFund->AccountNumber; ?>', 'Width=200px')); $this->dtgReport->AddColumn(new QDataGridColumn('Amount', '<?= QApplication::DisplayCurrencyHtml($_ITEM->Amount); ?>', 'HtmlEntities=false', 'Width=245px')); $this->dtgReport->NoDataHtml = 'Changes only to members credited. (No changes to funding accounts or amounts)'; $this->dtgReport->SetDataBinder('dtgReport_Funds_Bind'); break; case 'line_items': $this->dtgReport = new QDataGrid($this); $this->dtgReport->AddColumn(new QDataGridColumn('Person', '<?= $_ITEM->Person->Name; ?>', 'Width=200px')); $this->dtgReport->AddColumn(new QDataGridColumn('Fund', '<?= $_ITEM->StewardshipFund->Name; ?>', 'Width=200px')); $this->dtgReport->AddColumn(new QDataGridColumn('Description', '<?= $_ITEM->Description; ?>', 'Width=200px')); $this->dtgReport->AddColumn(new QDataGridColumn('Amount', '<?= QApplication::DisplayCurrencyHtml($_ITEM->Amount); ?>', 'HtmlEntities=false', 'Width=130px')); $this->dtgReport->SetDataBinder('dtgReport_LineItems_Bind'); break; default: QApplication::Redirect('/stewardship/'); break; } $this->objBatch = StewardshipBatch::Load(QApplication::PathInfo(1)); if (!$this->objBatch) { QApplication::Redirect('/stewardship/'); } $this->objPost = StewardshipPost::LoadByStewardshipBatchIdPostNumber($this->objBatch->Id, QApplication::PathInfo(2)); if (!$this->objPost) { QApplication::Redirect('/stewardship/'); } }
public static function GenerateStewardship() { $dttDate = new QDateTime('2004-01-05'); print 'Generating Stewardship... '; $objFundArray = StewardshipFund::QueryArray(QQ::NotEqual(QQN::StewardshipFund()->Id, 1)); while ($dttDate->IsEarlierThan(QDateTime::Now())) { print $strDate = '[' . $dttDate->ToString('YYYY-MMM-DD') . ']'; $intCheckCount = rand(10, 55); $arrStack = array(); for ($i = 0; $i < floor(($intCheckCount - 1) / 25) + 1; $i++) { $arrStack[] = null; } $objBatch = StewardshipBatch::Create(self::GenerateFromArray(self::$StewardshipUserArray), $arrStack, self::GenerateFromArray(array('Weekend T/O', 'Weekend Giving', 'Tithes and Offerings', 'Tithes & Offerings', null)), $dttDate, $dttDate); $intStackCount = $objBatch->CountStewardshipStacks(); $dttStart = new QDateTime($dttDate); $dttStart->SetTime(8, 0, 0); $dttEnd = new QDateTime($dttDate); $dttEnd->SetTime(16, 0, 0); for ($i = 0; $i < $intStackCount; $i++) { if ($i == $intStackCount - 1) { if ($intCheckCount % 25 == 0) { $intChecksInStackCount = 25; } else { $intChecksInStackCount = $intCheckCount % 25; } } else { $intChecksInStackCount = 25; } $objStack = StewardshipStack::LoadByStewardshipBatchIdStackNumber($objBatch->Id, $i + 1); for ($j = 0; $j < $intChecksInStackCount; $j++) { $objHousehold = self::GenerateFromArray(self::$HouseholdArray); $objHouseholdParticipant = self::GenerateFromArray($objHousehold->GetHouseholdParticipationArray()); $mixAmountArray = array(); if (rand(0, 50)) { $mixAmountArray[] = array(1, rand(1000, 150000) / 100); } else { $mixAmountArray[] = array(self::GenerateFromArray($objFundArray)->Id, rand(1000, 150000) / 100); } if (!rand(0, 20)) { $mixAmountArray[] = array(self::GenerateFromArray($objFundArray)->Id, rand(1000, 150000) / 100); } $objContribution = StewardshipContribution::Create($objBatch->CreatedByLogin, $objHouseholdParticipant->Person, $objStack, StewardshipContributionType::Check, rand(1000, 9999), $mixAmountArray, self::GenerateDateTime($dttStart, $dttEnd), null, null, null, false); if (rand(0, 5)) { $objContribution->SaveImageFile(__DEVTOOLS_CLI__ . '/datagen_file_assets/check.tif'); } } $objStack->RefreshActualTotalAmount(); } if ($intCheckCount != $objBatch->CountStewardshipContributions()) { print "\r\n" . 'MISCOUNT: ' . $objBatch->Id . "\r\n"; } $objBatch->RefreshActualTotalAmount(); $dttDate->Day += 7; print str_repeat(chr(8) . ' ' . chr(8), strlen($strDate)); } print "Done.\r\n"; }
public function btnSave_Click() { $fltArray = array(); foreach ($this->txtReportedTotals as $txtReportedTotal) { if ($txtReportedTotal->Visible) { if ($fltAmount = trim($txtReportedTotal->Text)) { $fltArray[] = $fltAmount; } else { $fltArray[] = null; } } } $objBatch = StewardshipBatch::Create(QApplication::$Login, $fltArray, trim($this->txtDescription->Text), null, $this->calDateCredited->DateTime); QApplication::Redirect('/stewardship/batch.php/' . $objBatch->Id . '#1'); }
/** * 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 StewardshipBatchMetaControl * @param integer $intId primary key value * @param QMetaControlCreateType $intCreateType rules governing StewardshipBatch object creation - defaults to CreateOrEdit * @return StewardshipBatchMetaControl */ public static function Create($objParentObject, $intId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) { // Attempt to Load from PK Arguments if (strlen($intId)) { $objStewardshipBatch = StewardshipBatch::Load($intId); // StewardshipBatch was found -- return it! if ($objStewardshipBatch) { return new StewardshipBatchMetaControl($objParentObject, $objStewardshipBatch); } else { if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) { throw new QCallerException('Could not find a StewardshipBatch 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 StewardshipBatchMetaControl($objParentObject, new StewardshipBatch()); }
/** * Refresh this MetaControl with Data from the local PaypalBatch object. * @param boolean $blnReload reload PaypalBatch from the database * @return void */ public function Refresh($blnReload = false) { if ($blnReload) { $this->objPaypalBatch->Reload(); } if ($this->lblId) { if ($this->blnEditMode) { $this->lblId->Text = $this->objPaypalBatch->Id; } } if ($this->txtNumber) { $this->txtNumber->Text = $this->objPaypalBatch->Number; } if ($this->lblNumber) { $this->lblNumber->Text = $this->objPaypalBatch->Number; } if ($this->calDateReceived) { $this->calDateReceived->DateTime = $this->objPaypalBatch->DateReceived; } if ($this->lblDateReceived) { $this->lblDateReceived->Text = sprintf($this->objPaypalBatch->DateReceived) ? $this->objPaypalBatch->__toString($this->strDateReceivedDateTimeFormat) : null; } if ($this->calDateReconciled) { $this->calDateReconciled->DateTime = $this->objPaypalBatch->DateReconciled; } if ($this->lblDateReconciled) { $this->lblDateReconciled->Text = sprintf($this->objPaypalBatch->DateReconciled) ? $this->objPaypalBatch->__toString($this->strDateReconciledDateTimeFormat) : null; } if ($this->chkReconciledFlag) { $this->chkReconciledFlag->Checked = $this->objPaypalBatch->ReconciledFlag; } if ($this->lblReconciledFlag) { $this->lblReconciledFlag->Text = $this->objPaypalBatch->ReconciledFlag ? QApplication::Translate('Yes') : QApplication::Translate('No'); } if ($this->lstStewardshipBatch) { $this->lstStewardshipBatch->RemoveAllItems(); $this->lstStewardshipBatch->AddItem(QApplication::Translate('- Select One -'), null); $objStewardshipBatchArray = StewardshipBatch::LoadAll(); if ($objStewardshipBatchArray) { foreach ($objStewardshipBatchArray as $objStewardshipBatch) { $objListItem = new QListItem($objStewardshipBatch->__toString(), $objStewardshipBatch->Id); if ($this->objPaypalBatch->StewardshipBatch && $this->objPaypalBatch->StewardshipBatch->Id == $objStewardshipBatch->Id) { $objListItem->Selected = true; } $this->lstStewardshipBatch->AddItem($objListItem); } } } if ($this->lblStewardshipBatchId) { $this->lblStewardshipBatchId->Text = $this->objPaypalBatch->StewardshipBatch ? $this->objPaypalBatch->StewardshipBatch->__toString() : null; } }
/** * Gets the total amount POSTED to each Fund for this batch. Returns as an array of float values, indexed by the StewardshipFundId * @return float[] */ public function GetPostedTotalsByStewardshipFundId() { $strQuery = 'SELECT SUM(amount) AS amount_sum, stewardship_fund_id ' . 'FROM stewardship_post_amount, stewardship_post ' . 'WHERE stewardship_post_id = stewardship_post.id ' . 'AND stewardship_batch_id=%s ' . 'GROUP BY stewardship_fund_id'; $strQuery = sprintf($strQuery, $this->intId); $objResult = StewardshipBatch::GetDatabase()->Query($strQuery); $fltArrayToReturn = array(); while ($objRow = $objResult->GetNextRow()) { $fltArrayToReturn[$objRow->GetColumn('stewardship_fund_id')] = $objRow->GetColumn('amount_sum'); } return $fltArrayToReturn; }
/** * Refresh this MetaControl with Data from the local StewardshipPost object. * @param boolean $blnReload reload StewardshipPost from the database * @return void */ public function Refresh($blnReload = false) { if ($blnReload) { $this->objStewardshipPost->Reload(); } if ($this->lblId) { if ($this->blnEditMode) { $this->lblId->Text = $this->objStewardshipPost->Id; } } if ($this->lstStewardshipBatch) { $this->lstStewardshipBatch->RemoveAllItems(); if (!$this->blnEditMode) { $this->lstStewardshipBatch->AddItem(QApplication::Translate('- Select One -'), null); } $objStewardshipBatchArray = StewardshipBatch::LoadAll(); if ($objStewardshipBatchArray) { foreach ($objStewardshipBatchArray as $objStewardshipBatch) { $objListItem = new QListItem($objStewardshipBatch->__toString(), $objStewardshipBatch->Id); if ($this->objStewardshipPost->StewardshipBatch && $this->objStewardshipPost->StewardshipBatch->Id == $objStewardshipBatch->Id) { $objListItem->Selected = true; } $this->lstStewardshipBatch->AddItem($objListItem); } } } if ($this->lblStewardshipBatchId) { $this->lblStewardshipBatchId->Text = $this->objStewardshipPost->StewardshipBatch ? $this->objStewardshipPost->StewardshipBatch->__toString() : null; } if ($this->txtPostNumber) { $this->txtPostNumber->Text = $this->objStewardshipPost->PostNumber; } if ($this->lblPostNumber) { $this->lblPostNumber->Text = $this->objStewardshipPost->PostNumber; } if ($this->calDatePosted) { $this->calDatePosted->DateTime = $this->objStewardshipPost->DatePosted; } if ($this->lblDatePosted) { $this->lblDatePosted->Text = sprintf($this->objStewardshipPost->DatePosted) ? $this->objStewardshipPost->__toString($this->strDatePostedDateTimeFormat) : null; } if ($this->txtTotalAmount) { $this->txtTotalAmount->Text = $this->objStewardshipPost->TotalAmount; } if ($this->lblTotalAmount) { $this->lblTotalAmount->Text = $this->objStewardshipPost->TotalAmount; } if ($this->lstCreatedByLogin) { $this->lstCreatedByLogin->RemoveAllItems(); if (!$this->blnEditMode) { $this->lstCreatedByLogin->AddItem(QApplication::Translate('- Select One -'), null); } $objCreatedByLoginArray = Login::LoadAll(); if ($objCreatedByLoginArray) { foreach ($objCreatedByLoginArray as $objCreatedByLogin) { $objListItem = new QListItem($objCreatedByLogin->__toString(), $objCreatedByLogin->Id); if ($this->objStewardshipPost->CreatedByLogin && $this->objStewardshipPost->CreatedByLogin->Id == $objCreatedByLogin->Id) { $objListItem->Selected = true; } $this->lstCreatedByLogin->AddItem($objListItem); } } } if ($this->lblCreatedByLoginId) { $this->lblCreatedByLoginId->Text = $this->objStewardshipPost->CreatedByLogin ? $this->objStewardshipPost->CreatedByLogin->__toString() : null; } }
/** * 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 = StewardshipBatch::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 StewardshipBatch, given the clauses above $this->DataSource = StewardshipBatch::QueryArray($objCondition, $objClauses); }
public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects) { if ($objObject->objPerson) { $objObject->objPerson = Person::GetSoapObjectFromObject($objObject->objPerson, false); } else { if (!$blnBindRelatedObjects) { $objObject->intPersonId = null; } } if ($objObject->objStewardshipBatch) { $objObject->objStewardshipBatch = StewardshipBatch::GetSoapObjectFromObject($objObject->objStewardshipBatch, false); } else { if (!$blnBindRelatedObjects) { $objObject->intStewardshipBatchId = null; } } if ($objObject->objStewardshipStack) { $objObject->objStewardshipStack = StewardshipStack::GetSoapObjectFromObject($objObject->objStewardshipStack, false); } else { if (!$blnBindRelatedObjects) { $objObject->intStewardshipStackId = null; } } if ($objObject->objCheckingAccountLookup) { $objObject->objCheckingAccountLookup = CheckingAccountLookup::GetSoapObjectFromObject($objObject->objCheckingAccountLookup, false); } else { if (!$blnBindRelatedObjects) { $objObject->intCheckingAccountLookupId = null; } } if ($objObject->dttDateEntered) { $objObject->dttDateEntered = $objObject->dttDateEntered->__toString(QDateTime::FormatSoap); } if ($objObject->dttDateCleared) { $objObject->dttDateCleared = $objObject->dttDateCleared->__toString(QDateTime::FormatSoap); } if ($objObject->dttDateCredited) { $objObject->dttDateCredited = $objObject->dttDateCredited->__toString(QDateTime::FormatSoap); } if ($objObject->objCreatedByLogin) { $objObject->objCreatedByLogin = Login::GetSoapObjectFromObject($objObject->objCreatedByLogin, false); } else { if (!$blnBindRelatedObjects) { $objObject->intCreatedByLoginId = null; } } return $objObject; }
/** * Refresh this MetaControl with Data from the local StewardshipContribution object. * @param boolean $blnReload reload StewardshipContribution from the database * @return void */ public function Refresh($blnReload = false) { if ($blnReload) { $this->objStewardshipContribution->Reload(); } if ($this->lblId) { if ($this->blnEditMode) { $this->lblId->Text = $this->objStewardshipContribution->Id; } } if ($this->lstPerson) { $this->lstPerson->RemoveAllItems(); if (!$this->blnEditMode) { $this->lstPerson->AddItem(QApplication::Translate('- Select One -'), null); } $objPersonArray = Person::LoadAll(); if ($objPersonArray) { foreach ($objPersonArray as $objPerson) { $objListItem = new QListItem($objPerson->__toString(), $objPerson->Id); if ($this->objStewardshipContribution->Person && $this->objStewardshipContribution->Person->Id == $objPerson->Id) { $objListItem->Selected = true; } $this->lstPerson->AddItem($objListItem); } } } if ($this->lblPersonId) { $this->lblPersonId->Text = $this->objStewardshipContribution->Person ? $this->objStewardshipContribution->Person->__toString() : null; } if ($this->lstStewardshipContributionType) { $this->lstStewardshipContributionType->SelectedValue = $this->objStewardshipContribution->StewardshipContributionTypeId; } if ($this->lblStewardshipContributionTypeId) { $this->lblStewardshipContributionTypeId->Text = $this->objStewardshipContribution->StewardshipContributionTypeId ? StewardshipContributionType::$NameArray[$this->objStewardshipContribution->StewardshipContributionTypeId] : null; } if ($this->lstStewardshipBatch) { $this->lstStewardshipBatch->RemoveAllItems(); if (!$this->blnEditMode) { $this->lstStewardshipBatch->AddItem(QApplication::Translate('- Select One -'), null); } $objStewardshipBatchArray = StewardshipBatch::LoadAll(); if ($objStewardshipBatchArray) { foreach ($objStewardshipBatchArray as $objStewardshipBatch) { $objListItem = new QListItem($objStewardshipBatch->__toString(), $objStewardshipBatch->Id); if ($this->objStewardshipContribution->StewardshipBatch && $this->objStewardshipContribution->StewardshipBatch->Id == $objStewardshipBatch->Id) { $objListItem->Selected = true; } $this->lstStewardshipBatch->AddItem($objListItem); } } } if ($this->lblStewardshipBatchId) { $this->lblStewardshipBatchId->Text = $this->objStewardshipContribution->StewardshipBatch ? $this->objStewardshipContribution->StewardshipBatch->__toString() : null; } if ($this->lstStewardshipStack) { $this->lstStewardshipStack->RemoveAllItems(); $this->lstStewardshipStack->AddItem(QApplication::Translate('- Select One -'), null); $objStewardshipStackArray = StewardshipStack::LoadAll(); if ($objStewardshipStackArray) { foreach ($objStewardshipStackArray as $objStewardshipStack) { $objListItem = new QListItem($objStewardshipStack->__toString(), $objStewardshipStack->Id); if ($this->objStewardshipContribution->StewardshipStack && $this->objStewardshipContribution->StewardshipStack->Id == $objStewardshipStack->Id) { $objListItem->Selected = true; } $this->lstStewardshipStack->AddItem($objListItem); } } } if ($this->lblStewardshipStackId) { $this->lblStewardshipStackId->Text = $this->objStewardshipContribution->StewardshipStack ? $this->objStewardshipContribution->StewardshipStack->__toString() : null; } if ($this->lstCheckingAccountLookup) { $this->lstCheckingAccountLookup->RemoveAllItems(); $this->lstCheckingAccountLookup->AddItem(QApplication::Translate('- Select One -'), null); $objCheckingAccountLookupArray = CheckingAccountLookup::LoadAll(); if ($objCheckingAccountLookupArray) { foreach ($objCheckingAccountLookupArray as $objCheckingAccountLookup) { $objListItem = new QListItem($objCheckingAccountLookup->__toString(), $objCheckingAccountLookup->Id); if ($this->objStewardshipContribution->CheckingAccountLookup && $this->objStewardshipContribution->CheckingAccountLookup->Id == $objCheckingAccountLookup->Id) { $objListItem->Selected = true; } $this->lstCheckingAccountLookup->AddItem($objListItem); } } } if ($this->lblCheckingAccountLookupId) { $this->lblCheckingAccountLookupId->Text = $this->objStewardshipContribution->CheckingAccountLookup ? $this->objStewardshipContribution->CheckingAccountLookup->__toString() : null; } if ($this->txtTotalAmount) { $this->txtTotalAmount->Text = $this->objStewardshipContribution->TotalAmount; } if ($this->lblTotalAmount) { $this->lblTotalAmount->Text = $this->objStewardshipContribution->TotalAmount; } if ($this->calDateEntered) { $this->calDateEntered->DateTime = $this->objStewardshipContribution->DateEntered; } if ($this->lblDateEntered) { $this->lblDateEntered->Text = sprintf($this->objStewardshipContribution->DateEntered) ? $this->objStewardshipContribution->__toString($this->strDateEnteredDateTimeFormat) : null; } if ($this->calDateCleared) { $this->calDateCleared->DateTime = $this->objStewardshipContribution->DateCleared; } if ($this->lblDateCleared) { $this->lblDateCleared->Text = sprintf($this->objStewardshipContribution->DateCleared) ? $this->objStewardshipContribution->__toString($this->strDateClearedDateTimeFormat) : null; } if ($this->calDateCredited) { $this->calDateCredited->DateTime = $this->objStewardshipContribution->DateCredited; } if ($this->lblDateCredited) { $this->lblDateCredited->Text = sprintf($this->objStewardshipContribution->DateCredited) ? $this->objStewardshipContribution->__toString($this->strDateCreditedDateTimeFormat) : null; } if ($this->txtCheckNumber) { $this->txtCheckNumber->Text = $this->objStewardshipContribution->CheckNumber; } if ($this->lblCheckNumber) { $this->lblCheckNumber->Text = $this->objStewardshipContribution->CheckNumber; } if ($this->txtAuthorizationNumber) { $this->txtAuthorizationNumber->Text = $this->objStewardshipContribution->AuthorizationNumber; } if ($this->lblAuthorizationNumber) { $this->lblAuthorizationNumber->Text = $this->objStewardshipContribution->AuthorizationNumber; } if ($this->txtAlternateSource) { $this->txtAlternateSource->Text = $this->objStewardshipContribution->AlternateSource; } if ($this->lblAlternateSource) { $this->lblAlternateSource->Text = $this->objStewardshipContribution->AlternateSource; } if ($this->chkNonDeductibleFlag) { $this->chkNonDeductibleFlag->Checked = $this->objStewardshipContribution->NonDeductibleFlag; } if ($this->lblNonDeductibleFlag) { $this->lblNonDeductibleFlag->Text = $this->objStewardshipContribution->NonDeductibleFlag ? QApplication::Translate('Yes') : QApplication::Translate('No'); } if ($this->txtNote) { $this->txtNote->Text = $this->objStewardshipContribution->Note; } if ($this->lblNote) { $this->lblNote->Text = $this->objStewardshipContribution->Note; } if ($this->lstCreatedByLogin) { $this->lstCreatedByLogin->RemoveAllItems(); if (!$this->blnEditMode) { $this->lstCreatedByLogin->AddItem(QApplication::Translate('- Select One -'), null); } $objCreatedByLoginArray = Login::LoadAll(); if ($objCreatedByLoginArray) { foreach ($objCreatedByLoginArray as $objCreatedByLogin) { $objListItem = new QListItem($objCreatedByLogin->__toString(), $objCreatedByLogin->Id); if ($this->objStewardshipContribution->CreatedByLogin && $this->objStewardshipContribution->CreatedByLogin->Id == $objCreatedByLogin->Id) { $objListItem->Selected = true; } $this->lstCreatedByLogin->AddItem($objListItem); } } } if ($this->lblCreatedByLoginId) { $this->lblCreatedByLoginId->Text = $this->objStewardshipContribution->CreatedByLogin ? $this->objStewardshipContribution->CreatedByLogin->__toString() : null; } if ($this->chkUnpostedFlag) { $this->chkUnpostedFlag->Checked = $this->objStewardshipContribution->UnpostedFlag; } if ($this->lblUnpostedFlag) { $this->lblUnpostedFlag->Text = $this->objStewardshipContribution->UnpostedFlag ? QApplication::Translate('Yes') : QApplication::Translate('No'); } if ($this->lstCreditCardPayment) { $this->lstCreditCardPayment->RemoveAllItems(); $this->lstCreditCardPayment->AddItem(QApplication::Translate('- Select One -'), null); $objCreditCardPaymentArray = CreditCardPayment::LoadAll(); if ($objCreditCardPaymentArray) { foreach ($objCreditCardPaymentArray as $objCreditCardPayment) { $objListItem = new QListItem($objCreditCardPayment->__toString(), $objCreditCardPayment->Id); if ($objCreditCardPayment->StewardshipContributionId == $this->objStewardshipContribution->Id) { $objListItem->Selected = true; } $this->lstCreditCardPayment->AddItem($objListItem); } } } if ($this->lblCreditCardPayment) { $this->lblCreditCardPayment->Text = $this->objStewardshipContribution->CreditCardPayment ? $this->objStewardshipContribution->CreditCardPayment->__toString() : null; } }
public function pxyDeleteStack_Click($strFormId, $strControlId, $strParameter) { if ($this->objStack && !$this->objStack->CountStewardshipContributions()) { $this->objStack->Delete(); if ($this->objBatch->CountStewardshipStacks()) { $this->objBatch->RefreshStackNumbering(); $this->pnlStacks_Refresh(true); $this->pnlBatchTitle->Refresh(); $this->objBatch->RefreshReportedTotalAmount(); QApplication::ExecuteJavaScript(sprintf('document.location="/stewardship/batch.php/%s";', $this->objBatch->Id)); } else { $this->objBatch->Delete(); $dttDateEntered = $this->objBatch->DateEntered; StewardshipBatch::RefreshBatchLettering($dttDateEntered); QApplication::Redirect('/stewardship/'); } } }
public static function GetSoapArrayFromArray($objArray) { if (!$objArray) { return null; } $objArrayToReturn = array(); foreach ($objArray as $objObject) { array_push($objArrayToReturn, StewardshipBatch::GetSoapObjectFromObject($objObject, true)); } return unserialize(serialize($objArrayToReturn)); }
public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects) { if ($objObject->objStewardshipBatch) { $objObject->objStewardshipBatch = StewardshipBatch::GetSoapObjectFromObject($objObject->objStewardshipBatch, false); } else { if (!$blnBindRelatedObjects) { $objObject->intStewardshipBatchId = null; } } return $objObject; }
/** * Deletes all associated StewardshipBatchesAsCreatedBy * @return void */ public function DeleteAllStewardshipBatchesAsCreatedBy() { if (is_null($this->intId)) { throw new QUndefinedPrimaryKeyException('Unable to call UnassociateStewardshipBatchAsCreatedBy on this unsaved Login.'); } // Get the Database Object for this Class $objDatabase = Login::GetDatabase(); // Journaling if ($objDatabase->JournalingDatabase) { foreach (StewardshipBatch::LoadArrayByCreatedByLoginId($this->intId) as $objStewardshipBatch) { $objStewardshipBatch->Journal('DELETE'); } } // Perform the SQL Query $objDatabase->NonQuery(' DELETE FROM `stewardship_batch` WHERE `created_by_login_id` = ' . $objDatabase->SqlVariable($this->intId) . ' '); }
public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects) { if ($objObject->objStewardshipBatch) { $objObject->objStewardshipBatch = StewardshipBatch::GetSoapObjectFromObject($objObject->objStewardshipBatch, false); } else { if (!$blnBindRelatedObjects) { $objObject->intStewardshipBatchId = null; } } if ($objObject->dttDatePosted) { $objObject->dttDatePosted = $objObject->dttDatePosted->__toString(QDateTime::FormatSoap); } if ($objObject->objCreatedByLogin) { $objObject->objCreatedByLogin = Login::GetSoapObjectFromObject($objObject->objCreatedByLogin, false); } else { if (!$blnBindRelatedObjects) { $objObject->intCreatedByLoginId = null; } } return $objObject; }
$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');
public function PostBatch(Login $objLogin, QDateTime $dttDateCredited) { if ($this->blnReconciledFlag) { throw new QCallerException('Cannot post a PayPal Batch that has already been reconciled!'); } // First, create the stewardship stacks into arrays of 100 $objToBecomeStacksArray = array(); $fltStackTotalsArray = array(); $fltRunningTotal = 0; $objCurrentStack = array(); foreach ($this->GetCreditCardPaymentArray(QQ::OrderBy(QQN::CreditCardPayment()->DateCaptured)) as $objCreditCardPayment) { if ($objCreditCardPayment->OnlineDonation || $objCreditCardPayment->SignupPayment && $objCreditCardPayment->SignupPayment->AmountDonation) { if (count($objCurrentStack) >= 100) { $objToBecomeStacksArray[] = $objCurrentStack; $fltStackTotalsArray[] = $fltRunningTotal; $objCurrentStack = array(); $fltRunningTotal = 0; } $objCurrentStack[] = $objCreditCardPayment; if ($objCreditCardPayment->OnlineDonation) { foreach ($objCreditCardPayment->OnlineDonation->GetOnlineDonationLineItemArray() as $objOnlineDonationLineItem) { if ($objOnlineDonationLineItem->DonationFlag) { $fltRunningTotal += $objOnlineDonationLineItem->Amount; } } } else { $fltRunningTotal += $objCreditCardPayment->SignupPayment->AmountDonation; } } } if (count($objCurrentStack)) { $objToBecomeStacksArray[] = $objCurrentStack; $fltStackTotalsArray[] = $fltRunningTotal; } // Start a Transaction PaypalBatch::GetDatabase()->TransactionBegin(); try { // Create the Batch $objBatch = StewardshipBatch::Create($objLogin, $fltStackTotalsArray, 'Stewardship Entries for PayPal Batch #' . $this->Number, QDateTime::Now(), $dttDateCredited); $objStackArray = $objBatch->GetStewardshipStackArray(QQ::OrderBy(QQN::StewardshipStack()->StackNumber)); if (count($objStackArray) != count($objToBecomeStacksArray)) { throw new Exception('Mismatch of Created Stacks vs. Calculated Stacks'); } // Create Each Stack for ($intStackIndex = 0; $intStackIndex < count($objStackArray); $intStackIndex++) { $objStack = $objStackArray[$intStackIndex]; $objPaymentArray = $objToBecomeStacksArray[$intStackIndex]; foreach ($objPaymentArray as $objPayment) { // Create a StewardshipContribution for each OnlineDonation entry if ($objPayment->OnlineDonation) { // First ensure we have a Donation AmountArray $objAmountArray = $objPayment->OnlineDonation->GetAmountArray(); if ($objAmountArray) { $objContribution = StewardshipContribution::Create($objLogin, $objPayment->OnlineDonation->Person, $objStack, StewardshipContributionType::CreditCard, $objPayment->TransactionCode, $objAmountArray, null, null, null, null, true); } else { $objContribution = null; } // Create a StewardshipContribution for the donation in a SignupPayment } else { $objContribution = StewardshipContribution::Create($objLogin, $objPayment->SignupPayment->SignupEntry->SignupByPerson, $objStack, StewardshipContributionType::CreditCard, $objPayment->TransactionCode, array(array($objPayment->SignupPayment->DonationStewardshipFundId, $objPayment->SignupPayment->AmountDonation)), null, null, null, null, true); } // Proceed if a Contribution was successfully created if ($objContribution) { // Fixup on the Contribution Object $objContribution->AlternateSource = $objPayment->CreditCardDescription; $objContribution->DateCredited = $dttDateCredited; $objContribution->Save(); // Fixup on the CCPayment Object to link back to the contribution object $objPayment->StewardshipContribution = $objContribution; $objPayment->Save(); } } } // Cleanup each Payment object foreach ($this->GetCreditCardPaymentArray() as $objCreditCardPayment) { $objCreditCardPayment->CreditCardStatusTypeId = CreditCardStatusType::Reconciled; $objCreditCardPayment->Save(); } // Cleanup this object $this->blnReconciledFlag = true; $this->dttDateReconciled = QDateTime::Now(); $this->StewardshipBatch = $objBatch; $this->Save(); // Finally, Post the StewardshipBatch $objBatch->PostBalance($objLogin); // If we are here, then it was a success! Commit the Transaction! PaypalBatch::GetDatabase()->TransactionCommit(); } catch (Exception $objExc) { PaypalBatch::GetDatabase()->TransactionRollBack(); throw $objExc; } }
/** * Refresh this MetaControl with Data from the local StewardshipStack object. * @param boolean $blnReload reload StewardshipStack from the database * @return void */ public function Refresh($blnReload = false) { if ($blnReload) { $this->objStewardshipStack->Reload(); } if ($this->lblId) { if ($this->blnEditMode) { $this->lblId->Text = $this->objStewardshipStack->Id; } } if ($this->lstStewardshipBatch) { $this->lstStewardshipBatch->RemoveAllItems(); if (!$this->blnEditMode) { $this->lstStewardshipBatch->AddItem(QApplication::Translate('- Select One -'), null); } $objStewardshipBatchArray = StewardshipBatch::LoadAll(); if ($objStewardshipBatchArray) { foreach ($objStewardshipBatchArray as $objStewardshipBatch) { $objListItem = new QListItem($objStewardshipBatch->__toString(), $objStewardshipBatch->Id); if ($this->objStewardshipStack->StewardshipBatch && $this->objStewardshipStack->StewardshipBatch->Id == $objStewardshipBatch->Id) { $objListItem->Selected = true; } $this->lstStewardshipBatch->AddItem($objListItem); } } } if ($this->lblStewardshipBatchId) { $this->lblStewardshipBatchId->Text = $this->objStewardshipStack->StewardshipBatch ? $this->objStewardshipStack->StewardshipBatch->__toString() : null; } if ($this->txtStackNumber) { $this->txtStackNumber->Text = $this->objStewardshipStack->StackNumber; } if ($this->lblStackNumber) { $this->lblStackNumber->Text = $this->objStewardshipStack->StackNumber; } if ($this->txtItemCount) { $this->txtItemCount->Text = $this->objStewardshipStack->ItemCount; } if ($this->lblItemCount) { $this->lblItemCount->Text = $this->objStewardshipStack->ItemCount; } if ($this->txtReportedTotalAmount) { $this->txtReportedTotalAmount->Text = $this->objStewardshipStack->ReportedTotalAmount; } if ($this->lblReportedTotalAmount) { $this->lblReportedTotalAmount->Text = $this->objStewardshipStack->ReportedTotalAmount; } if ($this->txtActualTotalAmount) { $this->txtActualTotalAmount->Text = $this->objStewardshipStack->ActualTotalAmount; } if ($this->lblActualTotalAmount) { $this->lblActualTotalAmount->Text = $this->objStewardshipStack->ActualTotalAmount; } }