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'; } }