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"; }
protected function Form_Create() { $this->dtgPledges = new StewardshipPledgeDataGrid($this); $this->dtgPledges->Paginator = new QPaginator($this->dtgPledges); $objCol = $this->dtgPledges->MetaAddColumn(QQN::StewardshipPledge()->Person->LastName, 'Name=Person', 'Html=<?= $_ITEM->Person->LinkHtml; ?>', 'Width=200px', 'HtmlEntities=false'); $objCol->OrderByClause = QQ::OrderBy(QQN::StewardshipPledge()->Person->LastName, QQN::StewardshipPledge()->Person->FirstName, QQN::StewardshipPledge()->Id); $this->dtgPledges->MetaAddColumn(QQN::StewardshipPledge()->StewardshipFund->Name, 'Name=Fund', 'Width=170px', 'FontSize=10px'); $this->dtgPledges->MetaAddColumn('PledgeAmount', 'Html=<?= $_FORM->RenderAmount($_ITEM, $_ITEM->PledgeAmount); ?>', 'HtmlEntities=false', 'Width=90px', 'Name=Pledged'); $this->dtgPledges->MetaAddColumn('RemainingAmount', 'Html=<?= $_FORM->RenderAmount($_ITEM, $_ITEM->RemainingAmount); ?>', 'HtmlEntities=false', 'Width=90px', 'Name=Remaining'); $this->dtgPledges->MetaAddColumn('DateStarted', 'Width=85px', 'FontSize=10px'); $this->dtgPledges->MetaAddColumn('DateEnded', 'Width=85px', 'FontSize=10px'); $this->dtgPledges->MetaAddColumn(QQN::StewardshipPledge()->FulfilledFlag, 'Html=<?= ($_ITEM->FulfilledFlag ? "Y" : ""); ?>', 'Name=Fulfilled?', 'Width=70px'); $this->dtgPledges->MetaAddColumn(QQN::StewardshipPledge()->ActiveFlag, 'Html=<?= $_FORM->RenderActiveFlag($_ITEM); ?>', 'Name=Active?', 'Width=70px', 'HtmlEntities=false'); $this->dtgPledges->SetDataBinder('dtgPledges_Bind'); $this->dtgPledges->NoDataHtml = '<strong>No results.</strong><br/>Please specify search parameters above.'; $this->dtgPledges->SortColumnIndex = 0; $this->dtgPledges->SortDirection = 0; $this->pxyActiveFlagToggle = new QControlProxy($this); $this->pxyActiveFlagToggle->AddAction(new QClickEvent(), new QAjaxAction('pxyActiveFlagToggle_Click')); $this->pxyActiveFlagToggle->AddAction(new QClickEvent(), new QTerminateAction()); $this->pxyActiveFlagToggleAll = new QControlProxy($this); $this->pxyActiveFlagToggleAll->AddAction(new QClickEvent(), new QAjaxAction('pxyActiveFlagToggleAll_Click')); $this->pxyActiveFlagToggleAll->AddAction(new QClickEvent(), new QTerminateAction()); $this->lstFund = new QListBox($this); $this->lstFund->AddItem('- View All -'); foreach (StewardshipFund::QueryArray(QQ::Equal(QQN::StewardshipFund()->ActiveFlag, true), QQ::OrderBy(QQN::StewardshipFund()->Name)) as $objFund) { if ($objFund->FundNumber) { $this->lstFund->AddItem($objFund->Name . ' (' . $objFund->FundNumber . ')', $objFund->Id); } else { $this->lstFund->AddItem($objFund->Name, $objFund->Id); } } $this->lstFund->AddAction(new QChangeEvent(), new QAjaxAction('ResetFilter')); $this->lstActiveFlag = new QListBox($this); $this->lstActiveFlag->AddItem('- View All -', null); $this->lstActiveFlag->AddItem('Active Only', true); $this->lstActiveFlag->AddItem('Inactive Only', false); $this->lstActiveFlag->AddAction(new QChangeEvent(), new QAjaxAction('ResetFilter')); $this->lstFulfilledFlag = new QListBox($this); $this->lstFulfilledFlag->AddItem('- View All -', null); $this->lstFulfilledFlag->AddItem('Fulfilled Only', true); $this->lstFulfilledFlag->AddItem('Not Yet Fulfilled Only', false, true); $this->lstFulfilledFlag->AddAction(new QChangeEvent(), new QAjaxAction('ResetFilter')); }
/** * Load an array of StewardshipFund objects, * by ExternalFlag Index(es) * @param boolean $blnExternalFlag * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query * @return StewardshipFund[] */ public static function LoadArrayByExternalFlag($blnExternalFlag, $objOptionalClauses = null) { // Call StewardshipFund::QueryArray to perform the LoadArrayByExternalFlag query try { return StewardshipFund::QueryArray(QQ::Equal(QQN::StewardshipFund()->ExternalFlag, $blnExternalFlag), $objOptionalClauses); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } }
/** * 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 = StewardshipFund::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 StewardshipFund, given the clauses above $this->DataSource = StewardshipFund::QueryArray($objCondition, $objClauses); }
protected function Form_Create() { $this->dtgContributions = new StewardshipContributionDataGrid($this); $this->dtgContributions->Paginator = new QPaginator($this->dtgContributions); $this->dtgContributions->MetaAddColumn(QQN::StewardshipContribution()->Person->LastName, 'Name=Person', 'Html=<?= $_ITEM->Id ? $_ITEM->Person->Name : "TOTAL"; ?>', 'Width=280px'); $this->dtgContributions->MetaAddColumn('TotalAmount', 'Html=<?= $_FORM->RenderAmount($_ITEM); ?>', 'HtmlEntities=false', 'Width=150px'); $this->dtgContributions->MetaAddColumn('CheckNumber', 'Width=120px'); $this->dtgContributions->MetaAddColumn('AuthorizationNumber', 'Width=140px'); $this->dtgContributions->MetaAddColumn(QQN::StewardshipContribution()->StewardshipBatch->DateEntered, 'Width=100px'); $this->dtgContributions->MetaAddColumn('DateCredited', 'Width=100px'); $this->dtgContributions->SetDataBinder('dtgContributions_Bind'); $this->dtgContributions->NoDataHtml = '<strong>No results.</strong><br/>Please specify search parameters above.'; $this->dtgContributions->SortColumnIndex = 0; $this->dtgContributions->SortDirection = 0; $this->btnCalculateTotal = new QButton($this); $this->btnCalculateTotal->CssClass = 'primary'; $this->btnCalculateTotal->Text = 'Calculate Total Amount'; $this->btnCalculateLabel = new QLabel($this); $this->btnCalculateLabel->Text = 'Calculating... <img src="/assets/images/spinner_14.gif"/>'; $this->btnCalculateLabel->Display = false; $this->btnCalculateLabel->HtmlEntities = false; $this->btnCalculateTotal->AddAction(new QClickEvent(), new QToggleDisplayAction($this->btnCalculateTotal)); $this->btnCalculateTotal->AddAction(new QClickEvent(), new QToggleDisplayAction($this->btnCalculateLabel)); $this->btnCalculateTotal->AddAction(new QClickEvent(), new QAjaxAction('btnCalculateTotal_Click')); $this->btnPrint = new QButton($this); $this->btnPrint->CssClass = 'alternate'; $this->btnPrint->Text = 'Print Results'; $this->btnPrintLabel = new QLabel($this); $this->btnPrintLabel->Text = 'Preparing to Print... <img src="/assets/images/spinner_14.gif"/>'; $this->btnPrintLabel->Display = false; $this->btnPrintLabel->HtmlEntities = false; $this->btnPrint->AddAction(new QClickEvent(), new QToggleDisplayAction($this->btnPrint)); $this->btnPrint->AddAction(new QClickEvent(), new QToggleDisplayAction($this->btnPrintLabel)); $this->btnPrint->AddAction(new QClickEvent(), new QAjaxAction('btnPrint_Click')); $this->txtName = new QTextBox($this); $this->txtDateEnteredStart = new QDateTimeTextBox($this); $this->txtDateEnteredEnd = new QDateTimeTextBox($this); $this->txtDateCreditedStart = new QDateTimeTextBox($this); $this->txtDateCreditedEnd = new QDateTimeTextBox($this); $this->txtAmount = new QFloatTextBox($this); $this->txtCheckNumber = new QTextBox($this); $this->txtAuthorizationNumber = new QTextBox($this); $this->lstFund = new QListBox($this); $this->txtDateCreditedStart->Text = 'Jan 1 ' . date('Y'); $this->txtDateCreditedEnd->Text = 'Dec 31 ' . date('Y'); $this->lstFund->AddItem('- View All -'); foreach (StewardshipFund::QueryArray(QQ::Equal(QQN::StewardshipFund()->ActiveFlag, true), QQ::OrderBy(QQN::StewardshipFund()->Name)) as $objFund) { if ($objFund->FundNumber) { $this->lstFund->AddItem($objFund->Name . ' (' . $objFund->FundNumber . ')', $objFund->Id); } else { $this->lstFund->AddItem($objFund->Name, $objFund->Id); } } $this->lstFund->AddAction(new QChangeEvent(), new QAjaxAction('ResetFilter')); $this->txtName->AddAction(new QEnterKeyEvent(), new QAjaxAction('ResetFilter')); $this->txtName->AddAction(new QEnterKeyEvent(), new QTerminateAction()); $this->txtName->AddAction(new QChangeEvent(), new QAjaxAction('ResetFilter')); $this->txtDateEnteredStart->AddAction(new QEnterKeyEvent(), new QAjaxAction('ResetFilter')); $this->txtDateEnteredStart->AddAction(new QEnterKeyEvent(), new QTerminateAction()); $this->txtDateEnteredStart->AddAction(new QChangeEvent(), new QAjaxAction('ResetFilter')); $this->txtDateEnteredEnd->AddAction(new QEnterKeyEvent(), new QAjaxAction('ResetFilter')); $this->txtDateEnteredEnd->AddAction(new QEnterKeyEvent(), new QTerminateAction()); $this->txtDateEnteredEnd->AddAction(new QChangeEvent(), new QAjaxAction('ResetFilter')); $this->txtDateCreditedStart->AddAction(new QEnterKeyEvent(), new QAjaxAction('ResetFilter')); $this->txtDateCreditedStart->AddAction(new QEnterKeyEvent(), new QTerminateAction()); $this->txtDateCreditedStart->AddAction(new QChangeEvent(), new QAjaxAction('ResetFilter')); $this->txtDateCreditedEnd->AddAction(new QEnterKeyEvent(), new QAjaxAction('ResetFilter')); $this->txtDateCreditedEnd->AddAction(new QEnterKeyEvent(), new QTerminateAction()); $this->txtDateCreditedEnd->AddAction(new QChangeEvent(), new QAjaxAction('ResetFilter')); $this->txtAmount->AddAction(new QEnterKeyEvent(), new QAjaxAction('ResetFilter')); $this->txtAmount->AddAction(new QEnterKeyEvent(), new QTerminateAction()); $this->txtAmount->AddAction(new QChangeEvent(), new QAjaxAction('ResetFilter')); $this->txtCheckNumber->AddAction(new QEnterKeyEvent(), new QAjaxAction('ResetFilter')); $this->txtCheckNumber->AddAction(new QEnterKeyEvent(), new QTerminateAction()); $this->txtCheckNumber->AddAction(new QChangeEvent(), new QAjaxAction('ResetFilter')); $this->txtAuthorizationNumber->AddAction(new QEnterKeyEvent(), new QAjaxAction('ResetFilter')); $this->txtAuthorizationNumber->AddAction(new QEnterKeyEvent(), new QTerminateAction()); $this->txtAuthorizationNumber->AddAction(new QChangeEvent(), new QAjaxAction('ResetFilter')); }