public function RenderCount(StewardshipPost $objPost) { if ($objPost->Id) { return $objPost->CountStewardshipPostLineItems(); } else { return StewardshipContribution::CountByStewardshipBatchIdUnpostedFlag($this->objBatch->Id, true); } }
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/'); } }
protected function Form_Create() { $this->lstYear = new QListBox($this); for ($intYear = 2002; $intYear <= date('Y'); $intYear++) { $this->lstYear->AddItem($intYear, $intYear, QApplication::PathInfo(0) ? QApplication::PathInfo(0) == $intYear : $intYear == QDateTime::Now()->Year); } $this->lstMonth = new QListBox($this); for ($intMonth = 1; $intMonth <= 12; $intMonth++) { $dttDate = new QDateTime('2000-' . $intMonth . '-01'); $this->lstMonth->AddItem($dttDate->ToString('MMMM'), $intMonth, QApplication::PathInfo(1) ? QApplication::PathInfo(1) == $intMonth : $intMonth == QDateTime::Now()->Month); } $this->lstYear->AddAction(new QChangeEvent(), new QAjaxAction('lstDate_Change')); $this->lstMonth->AddAction(new QChangeEvent(), new QAjaxAction('lstDate_Change')); $this->dtgReport = new QDataGrid($this); $this->dtgReport->AddColumn(new QDataGridColumn('Fund', '<?= $_FORM->RenderRow($_ITEM); ?><?= StewardshipFund::Load($_ITEM[0])->Name; ?>', 'Width=400px')); $this->dtgReport->AddColumn(new QDataGridColumn('Monthly Total', '<?= QApplication::DisplayCurrency($_ITEM[1]); ?>', 'Width=400px')); $this->dtgReport->AddColumn(new QDataGridColumn('YTD', '<?= QApplication::DisplayCurrency($_ITEM[2]); ?>', 'Width=400px')); $this->dttDate = new QDateTime($this->lstYear->SelectedValue . '-' . $this->lstMonth->SelectedValue . '-01'); $this->dttDate->SetTime(null, null, null); // Get the Data $objReportArray = StewardshipPost::GetReportByFundAndMonth($this->dttDate); $objReportYtdArray = StewardshipPost::GetReportYtdByFundForMonth($this->dttDate); // Setup the data holders $this->fltTotal = 0; $this->fltTotalYtd = 0; $objArray = array(); foreach ($objReportArray as $objLineItem) { $objFund = StewardshipFund::Load($objLineItem[0]); if ($objFund->AccountNumber == '7011.010' || substr($objFund->AccountNumber, 0, 1) == '4') { $this->fltTotal += $objLineItem[1]; $objArray[$objLineItem[0]] = array($objLineItem[0], $objLineItem[1], null); } } foreach ($objReportYtdArray as $objLineItem) { $objFund = StewardshipFund::Load($objLineItem[0]); if ($objFund->AccountNumber == '7011.010' || substr($objFund->AccountNumber, 0, 1) == '4') { $this->fltTotalYtd += $objLineItem[1]; if (array_key_exists($objLineItem[0], $objArray)) { $objArray[$objLineItem[0]][2] = $objLineItem[1]; } else { $objArray[$objLineItem[0]] = array($objLineItem[0], null, $objLineItem[1]); } } } // Bind the data $this->dtgReport->DataSource = $objArray; }
protected function SetupPanel() { $this->objPost = StewardshipPost::LoadByStewardshipBatchIdPostNumber($this->objBatch->Id, $this->strUrlHashArgument); $this->btnSave->Text = 'Post Unposted Funds'; $this->btnSave->RemoveAllActions(QClickEvent::EventName); $this->btnSave->AddAction(new QClickEvent(), new QConfirmAction('Are you SURE you want to POST these funds? This cannot be undone.')); $this->btnSave->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnSave_Click')); $this->btnSave->Visible = false; if ($this->objPost) { $this->dtgFunds = new QDataGrid($this); $this->dtgFunds->AddColumn(new QDataGridColumn('Fund', '<?= $_ITEM->StewardshipFund->Name; ?>', 'Width=340px')); $this->dtgFunds->AddColumn(new QDataGridColumn('Account Number', '<?= $_ITEM->StewardshipFund->AccountNumber; ?>', 'Width=200px')); $this->dtgFunds->AddColumn(new QDataGridColumn('Amount', '<?= QApplication::DisplayCurrencyHtml($_ITEM->Amount); ?>', 'HtmlEntities=false', 'Width=200px')); $this->dtgFunds->NoDataHtml = 'Changes only to members credited. (No changes to funding accounts or amounts)'; $this->dtgFunds->SetDataBinder('dtgFunds_Posted_Bind', $this); $this->dtgLineItems = new QDataGrid($this); $this->dtgLineItems->AddColumn(new QDataGridColumn('Person', '<?= $_ITEM->Person->Name; ?>', 'Width=200px')); $this->dtgLineItems->AddColumn(new QDataGridColumn('Fund', '<?= $_CONTROL->ParentControl->RenderStewardshipFundName($_ITEM); ?>', 'Width=200px', 'HtmlEntities=false')); $this->dtgLineItems->AddColumn(new QDataGridColumn('Description', '<?= $_ITEM->Description; ?>', 'Width=200px')); $this->dtgLineItems->AddColumn(new QDataGridColumn('Amount', '<?= QApplication::DisplayCurrencyHtml($_ITEM->Amount); ?>', 'HtmlEntities=false', 'Width=130px')); $this->dtgLineItems->SetDataBinder('dtgLineItems_Posted_Bind', $this); } else { if ($this->objBatch->StewardshipBatchStatusTypeId != StewardshipBatchStatusType::PostedInFull) { $this->dtgFunds = new QDataGrid($this); $this->dtgFunds->AddColumn(new QDataGridColumn('Fund', '<?= $_ITEM[0]; ?>', 'Width=500px')); $this->dtgFunds->AddColumn(new QDataGridColumn('Amount', '<?= $_ITEM[1]; ?>', 'HtmlEntities=false', 'Width=245px')); $this->dtgFunds->NoDataHtml = 'Changes only to members credited. (No changes to funding accounts or amounts)'; $this->dtgFunds->SetDataBinder('dtgFunds_Unposted_Bind', $this); $this->dtgLineItems = new QDataGrid($this); $this->dtgLineItems->AddColumn(new QDataGridColumn('Person', '<?= $_ITEM->StewardshipContribution->Person->Name; ?>', 'Width=300px')); $this->dtgLineItems->AddColumn(new QDataGridColumn('Fund', '<?= $_CONTROL->ParentControl->RenderStewardshipFundName($_ITEM); ?>', 'Width=300px', 'HtmlEntities=false')); $this->dtgLineItems->AddColumn(new QDataGridColumn('Amount', '<?= QApplication::DisplayCurrencyHtml($_ITEM->Amount); ?>', 'HtmlEntities=false', 'Width=130px')); $this->dtgLineItems->SetDataBinder('dtgLineItems_Unposted_Bind', $this); $this->btnSave->Visible = true; } else { return $this->ReturnTo('#/post_batch'); } } }
public static function GetSoapArrayFromArray($objArray) { if (!$objArray) { return null; } $objArrayToReturn = array(); foreach ($objArray as $objObject) { array_push($objArrayToReturn, StewardshipPost::GetSoapObjectFromObject($objObject, true)); } return unserialize(serialize($objArrayToReturn)); }
public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects) { if ($objObject->objStewardshipPost) { $objObject->objStewardshipPost = StewardshipPost::GetSoapObjectFromObject($objObject->objStewardshipPost, false); } else { if (!$blnBindRelatedObjects) { $objObject->intStewardshipPostId = null; } } if ($objObject->objStewardshipContribution) { $objObject->objStewardshipContribution = StewardshipContribution::GetSoapObjectFromObject($objObject->objStewardshipContribution, false); } else { if (!$blnBindRelatedObjects) { $objObject->intStewardshipContributionId = null; } } if ($objObject->objPerson) { $objObject->objPerson = Person::GetSoapObjectFromObject($objObject->objPerson, false); } else { if (!$blnBindRelatedObjects) { $objObject->intPersonId = null; } } if ($objObject->objStewardshipFund) { $objObject->objStewardshipFund = StewardshipFund::GetSoapObjectFromObject($objObject->objStewardshipFund, false); } else { if (!$blnBindRelatedObjects) { $objObject->intStewardshipFundId = null; } } return $objObject; }
/** * Refresh this MetaControl with Data from the local StewardshipPostAmount object. * @param boolean $blnReload reload StewardshipPostAmount from the database * @return void */ public function Refresh($blnReload = false) { if ($blnReload) { $this->objStewardshipPostAmount->Reload(); } if ($this->lblId) { if ($this->blnEditMode) { $this->lblId->Text = $this->objStewardshipPostAmount->Id; } } if ($this->lstStewardshipPost) { $this->lstStewardshipPost->RemoveAllItems(); if (!$this->blnEditMode) { $this->lstStewardshipPost->AddItem(QApplication::Translate('- Select One -'), null); } $objStewardshipPostArray = StewardshipPost::LoadAll(); if ($objStewardshipPostArray) { foreach ($objStewardshipPostArray as $objStewardshipPost) { $objListItem = new QListItem($objStewardshipPost->__toString(), $objStewardshipPost->Id); if ($this->objStewardshipPostAmount->StewardshipPost && $this->objStewardshipPostAmount->StewardshipPost->Id == $objStewardshipPost->Id) { $objListItem->Selected = true; } $this->lstStewardshipPost->AddItem($objListItem); } } } if ($this->lblStewardshipPostId) { $this->lblStewardshipPostId->Text = $this->objStewardshipPostAmount->StewardshipPost ? $this->objStewardshipPostAmount->StewardshipPost->__toString() : null; } if ($this->lstStewardshipFund) { $this->lstStewardshipFund->RemoveAllItems(); if (!$this->blnEditMode) { $this->lstStewardshipFund->AddItem(QApplication::Translate('- Select One -'), null); } $objStewardshipFundArray = StewardshipFund::LoadAll(); if ($objStewardshipFundArray) { foreach ($objStewardshipFundArray as $objStewardshipFund) { $objListItem = new QListItem($objStewardshipFund->__toString(), $objStewardshipFund->Id); if ($this->objStewardshipPostAmount->StewardshipFund && $this->objStewardshipPostAmount->StewardshipFund->Id == $objStewardshipFund->Id) { $objListItem->Selected = true; } $this->lstStewardshipFund->AddItem($objListItem); } } } if ($this->lblStewardshipFundId) { $this->lblStewardshipFundId->Text = $this->objStewardshipPostAmount->StewardshipFund ? $this->objStewardshipPostAmount->StewardshipFund->__toString() : null; } if ($this->txtAmount) { $this->txtAmount->Text = $this->objStewardshipPostAmount->Amount; } if ($this->lblAmount) { $this->lblAmount->Text = $this->objStewardshipPostAmount->Amount; } }
/** * Performs a Post of any balance on the batch. * @param Login $objLogin * @return StewardshipPost $objPost the actual post object if posted, or null if nothing was needed to be posted */ public function PostBalance(Login $objLogin) { $objPost = null; $fltBalanceArray = $this->GetUnpostedBalanceByStewardshipFundId(); if (count($fltBalanceArray) || StewardshipContribution::CountByStewardshipBatchIdUnpostedFlag($this->intId, true)) { $objLastPost = StewardshipPost::QuerySingle(QQ::Equal(QQN::StewardshipPost()->StewardshipBatchId, $this->intId), QQ::OrderBy(QQN::StewardshipPost()->PostNumber, false)); if ($objLastPost) { $intPostNumber = $objLastPost->PostNumber + 1; } else { $intPostNumber = 1; } $objPost = new StewardshipPost(); $objPost->StewardshipBatch = $this; $objPost->PostNumber = $intPostNumber; $objPost->DatePosted = QDateTime::Now(); $objPost->CreatedByLoginId = $objLogin->Id; $objPost->Save(); // It is possible (Due to status caching) that this can be called when there is actually nothing to post // If this happens, we'll want to delete the Post" $blnPosted = false; $fltTotalAmount = 0; foreach ($fltBalanceArray as $intFundId => $fltAmount) { $blnPosted = true; $objPostAmount = new StewardshipPostAmount(); $objPostAmount->StewardshipPostId = $objPost->Id; $objPostAmount->StewardshipFundId = $intFundId; $objPostAmount->Amount = $fltAmount; $objPostAmount->Save(); $fltTotalAmount += $fltAmount; } $objPost->TotalAmount = $fltTotalAmount; $objPost->Save(); // Add the Line Items foreach (StewardshipContribution::LoadArrayByStewardshipBatchIdUnpostedFlag($this->intId, true) as $objContribution) { if ($objContribution->PostLineItems($objPost)) { $blnPosted = true; } } // if NOTHING was physically posted, then delete the Post object. if (!$blnPosted) { $objPost->Delete(); $objPost = null; } } $this->RefreshStatus(); // Let's refresh the descriptions foreach ($this->GetStewardshipPostArray() as $objPostToRefresh) { foreach ($objPostToRefresh->GetStewardshipPostLineItemArray() as $objPostLineItem) { $objPostLineItem->RefreshDescription(); } } return $objPost; }
/** * 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 StewardshipPostMetaControl * @param integer $intId primary key value * @param QMetaControlCreateType $intCreateType rules governing StewardshipPost object creation - defaults to CreateOrEdit * @return StewardshipPostMetaControl */ public static function Create($objParentObject, $intId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) { // Attempt to Load from PK Arguments if (strlen($intId)) { $objStewardshipPost = StewardshipPost::Load($intId); // StewardshipPost was found -- return it! if ($objStewardshipPost) { return new StewardshipPostMetaControl($objParentObject, $objStewardshipPost); } else { if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) { throw new QCallerException('Could not find a StewardshipPost 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 StewardshipPostMetaControl($objParentObject, new StewardshipPost()); }
/** * 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 = StewardshipPost::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 StewardshipPost, given the clauses above $this->DataSource = StewardshipPost::QueryArray($objCondition, $objClauses); }
/** * Deletes all associated StewardshipPosts * @return void */ public function DeleteAllStewardshipPosts() { if (is_null($this->intId)) { throw new QUndefinedPrimaryKeyException('Unable to call UnassociateStewardshipPost on this unsaved StewardshipBatch.'); } // Get the Database Object for this Class $objDatabase = StewardshipBatch::GetDatabase(); // Journaling if ($objDatabase->JournalingDatabase) { foreach (StewardshipPost::LoadArrayByStewardshipBatchId($this->intId) as $objStewardshipPost) { $objStewardshipPost->Journal('DELETE'); } } // Perform the SQL Query $objDatabase->NonQuery(' DELETE FROM `stewardship_post` WHERE `stewardship_batch_id` = ' . $objDatabase->SqlVariable($this->intId) . ' '); }