Beispiel #1
0
 protected function Form_Create()
 {
     if (QApplication::PathInfo(0) == 'edit') {
         $this->isEdit = true;
         $this->objRecurringDonation = RecurringDonation::Load(QApplication::PathInfo(1));
     } else {
         $this->isEdit = false;
         $this->objRecurringDonation = null;
     }
     $this->chkAgreement = new QCheckBox($this);
     $this->chkAgreement->Text = 'I agree to allow recurring payments from my credit card';
     if ($this->isEdit) {
         $this->chkAgreement->Checked = $this->objRecurringDonation->RecurringPayment->AuthorizeFlag;
     }
     $this->txtPaymentName = new QTextBox($this);
     $this->txtPaymentName->HtmlBefore = 'Recuring Payment Name: ';
     if ($this->isEdit) {
         $this->txtPaymentName->Text = $this->objRecurringDonation->RecurringPayment->Name;
     }
     // Online Tithes and Offering = 28
     $this->objDonationItemArray = array();
     if ($this->isEdit) {
         $objDonationItems = RecurringDonationItems::LoadArrayByRecurringDonationId(QApplication::PathInfo(1));
         foreach ($objDonationItems as $objDonationItem) {
             $this->objDonationItemArray[] = $objDonationItem;
         }
         $objDonationItem = new RecurringDonationItems();
         $this->objDonationItemArray[] = $objDonationItem;
     } else {
         $objDonationItem = new RecurringDonationItems();
         $objDonationItem->StewardshipFundId = 28;
         $this->objDonationItemArray[] = $objDonationItem;
         $objDonationItem = new RecurringDonationItems();
         $this->objDonationItemArray[] = $objDonationItem;
     }
     $this->dtgDonationItems = new QDataGrid($this);
     $this->dtgDonationItems->AddColumn(new QDataGridColumn('Fund', '<?= $_FORM->RenderFund($_ITEM); ?>', 'HtmlEntities=false', 'Width=650px'));
     $this->dtgDonationItems->AddColumn(new QDataGridColumn('Amount', '<?= $_FORM->RenderAmount($_ITEM); ?>', 'HtmlEntities=false', 'Width=225px'));
     $this->dtgDonationItems->SetDataBinder('dtgDonationItems_Bind');
     // Total Label
     $this->lblTotal = new QLabel($this->dtgDonationItems);
     $this->lblTotal->FontBold = true;
     $this->lblTotal->Text = '$ 0.00';
     $this->lstPaymentPeriod = new QListBox($this);
     $this->lstPaymentPeriod->AddItem('- Select One -', null);
     $objPaymentPeriodArray = PaymentPeriod::LoadAll();
     foreach ($objPaymentPeriodArray as $objPaymentPeriod) {
         if ($this->isEdit) {
             $this->lstPaymentPeriod->AddItem($objPaymentPeriod->Name, $objPaymentPeriod->Id, $objPaymentPeriod->Id == $this->objRecurringDonation->RecurringPayment->PaymentPeriodId);
         } else {
             $this->lstPaymentPeriod->AddItem($objPaymentPeriod->Name, $objPaymentPeriod->Id, false);
         }
     }
     $this->dtxStartDate = new QDateTimeTextBox($this);
     $this->dtxStartDate->Name = "Start Date";
     if ($this->isEdit) {
         $this->dtxStartDate->Text = $this->objRecurringDonation->RecurringPayment->StartDate ? $this->objRecurringDonation->RecurringPayment->StartDate->__toString() : null;
     }
     $this->calStartDate = new QCalendar($this, $this->dtxStartDate);
     $this->dtxStartDate->RemoveAllActions(QClickEvent::EventName);
     $this->dtxEndDate = new QDateTimeTextBox($this);
     $this->dtxEndDate->Name = "End Date";
     if ($this->isEdit) {
         $this->dtxEndDate->Text = $this->objRecurringDonation->RecurringPayment->EndDate ? $this->objRecurringDonation->RecurringPayment->EndDate->__toString() : null;
     }
     $this->calEndDate = new QCalendar($this, $this->dtxEndDate);
     $this->dtxEndDate->RemoveAllActions(QClickEvent::EventName);
     // Create the Payment Panel GJS- will eventually have to create a different payment panel class
     // Figure out which address to use
     if (QApplication::$PublicLogin) {
         $objAddress = QApplication::$PublicLogin->Person->DeducePrimaryAddress();
     } else {
         $objAddress = new Address();
     }
     $strFirstName = QApplication::$PublicLogin ? QApplication::$PublicLogin->Person->FirstName : null;
     $strLastName = QApplication::$PublicLogin ? QApplication::$PublicLogin->Person->LastName : null;
     if ($this->isEdit) {
         $this->pnlPayment = new RecurringPaymentPanel($this, null, $objAddress, $strFirstName, $strLastName, $this->objRecurringDonation->RecurringPayment);
     } else {
         $this->pnlPayment = new RecurringPaymentPanel($this, null, $objAddress, $strFirstName, $strLastName, null);
     }
     $this->dtgPaymentHistory = new OnlineDonationDataGrid($this);
     $this->dtgPaymentHistory->Paginator = new QPaginator($this->dtgPaymentHistory);
     $this->dtgPaymentHistory->AddColumn(new QDataGridColumn('Date', '<?= $_FORM->RenderDate($_ITEM); ?>', 'HtmlEntities=false', 'Width=250px'));
     $this->dtgPaymentHistory->MetaAddColumn('Amount', 'Html=$<?=$_ITEM->Amount; ?>', 'HtmlEntities=false', 'Width=100px');
     $this->dtgPaymentHistory->AddColumn(new QDataGridColumn('Status', '<?= $_FORM->RenderStatus($_ITEM); ?>', 'HtmlEntities=false', 'Width=200px'));
     $this->dtgPaymentHistory->SetDataBinder('dtgPaymentHistory_Bind');
     $this->dtgPaymentHistory->NoDataHtml = 'No Payment History.';
     $this->dtgPaymentHistory->SortColumnIndex = 1;
     $this->dtgPaymentHistory->ItemsPerPage = 20;
     $this->btnAdd = new QButton($this);
     if ($this->isEdit) {
         $this->btnAdd->Name = 'Update Recurring Payment Information';
         $this->btnAdd->Text = 'Update Recurring Payment Information';
     } else {
         $this->btnAdd->Name = 'Add Recurring Payment Information';
         $this->btnAdd->Text = 'Add Recurring Payment Information';
     }
     $this->btnAdd->CssClass = 'primary';
     $this->btnAdd->AddAction(new QClickEvent(), new QAjaxAction('btnAdd_Click'));
     $this->btnCancel = new QButton($this);
     $this->btnCancel->Name = 'Return to Recurring Payments';
     $this->btnCancel->Text = 'Return to Recurring Payments';
     $this->btnCancel->CssClass = 'primary';
     $this->btnCancel->AddAction(new QClickEvent(), new QAjaxAction('btnCancel_Click'));
     $this->btnBack = new QButton($this);
     $this->btnBack->Name = 'Return To Give Online';
     $this->btnBack->Text = 'Return To Give Online';
     $this->btnBack->CssClass = 'primary';
     $this->btnBack->AddAction(new QClickEvent(), new QAjaxAction('btnBack_Click'));
 }
 /**
  * Refresh this MetaControl with Data from the local RecurringPayments object.
  * @param boolean $blnReload reload RecurringPayments from the database
  * @return void
  */
 public function Refresh($blnReload = false)
 {
     if ($blnReload) {
         $this->objRecurringPayments->Reload();
     }
     if ($this->lblId) {
         if ($this->blnEditMode) {
             $this->lblId->Text = $this->objRecurringPayments->Id;
         }
     }
     if ($this->txtName) {
         $this->txtName->Text = $this->objRecurringPayments->Name;
     }
     if ($this->lblName) {
         $this->lblName->Text = $this->objRecurringPayments->Name;
     }
     if ($this->lstPaymentPeriod) {
         $this->lstPaymentPeriod->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstPaymentPeriod->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objPaymentPeriodArray = PaymentPeriod::LoadAll();
         if ($objPaymentPeriodArray) {
             foreach ($objPaymentPeriodArray as $objPaymentPeriod) {
                 $objListItem = new QListItem($objPaymentPeriod->__toString(), $objPaymentPeriod->Id);
                 if ($this->objRecurringPayments->PaymentPeriod && $this->objRecurringPayments->PaymentPeriod->Id == $objPaymentPeriod->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstPaymentPeriod->AddItem($objListItem);
             }
         }
     }
     if ($this->lblPaymentPeriodId) {
         $this->lblPaymentPeriodId->Text = $this->objRecurringPayments->PaymentPeriod ? $this->objRecurringPayments->PaymentPeriod->__toString() : null;
     }
     if ($this->txtAmount) {
         $this->txtAmount->Text = $this->objRecurringPayments->Amount;
     }
     if ($this->lblAmount) {
         $this->lblAmount->Text = $this->objRecurringPayments->Amount;
     }
     if ($this->calStartDate) {
         $this->calStartDate->DateTime = $this->objRecurringPayments->StartDate;
     }
     if ($this->lblStartDate) {
         $this->lblStartDate->Text = sprintf($this->objRecurringPayments->StartDate) ? $this->objRecurringPayments->__toString($this->strStartDateDateTimeFormat) : null;
     }
     if ($this->calEndDate) {
         $this->calEndDate->DateTime = $this->objRecurringPayments->EndDate;
     }
     if ($this->lblEndDate) {
         $this->lblEndDate->Text = sprintf($this->objRecurringPayments->EndDate) ? $this->objRecurringPayments->__toString($this->strEndDateDateTimeFormat) : null;
     }
     if ($this->chkAuthorizeFlag) {
         $this->chkAuthorizeFlag->Checked = $this->objRecurringPayments->AuthorizeFlag;
     }
     if ($this->lblAuthorizeFlag) {
         $this->lblAuthorizeFlag->Text = $this->objRecurringPayments->AuthorizeFlag ? QApplication::Translate('Yes') : QApplication::Translate('No');
     }
     if ($this->txtCardHolderName) {
         $this->txtCardHolderName->Text = $this->objRecurringPayments->CardHolderName;
     }
     if ($this->lblCardHolderName) {
         $this->lblCardHolderName->Text = $this->objRecurringPayments->CardHolderName;
     }
     if ($this->txtAddress1) {
         $this->txtAddress1->Text = $this->objRecurringPayments->Address1;
     }
     if ($this->lblAddress1) {
         $this->lblAddress1->Text = $this->objRecurringPayments->Address1;
     }
     if ($this->txtAddress2) {
         $this->txtAddress2->Text = $this->objRecurringPayments->Address2;
     }
     if ($this->lblAddress2) {
         $this->lblAddress2->Text = $this->objRecurringPayments->Address2;
     }
     if ($this->txtCity) {
         $this->txtCity->Text = $this->objRecurringPayments->City;
     }
     if ($this->lblCity) {
         $this->lblCity->Text = $this->objRecurringPayments->City;
     }
     if ($this->txtState) {
         $this->txtState->Text = $this->objRecurringPayments->State;
     }
     if ($this->lblState) {
         $this->lblState->Text = $this->objRecurringPayments->State;
     }
     if ($this->txtZip) {
         $this->txtZip->Text = $this->objRecurringPayments->Zip;
     }
     if ($this->lblZip) {
         $this->lblZip->Text = $this->objRecurringPayments->Zip;
     }
     if ($this->lstCreditCardType) {
         $this->lstCreditCardType->SelectedValue = $this->objRecurringPayments->CreditCardTypeId;
     }
     if ($this->lblCreditCardTypeId) {
         $this->lblCreditCardTypeId->Text = $this->objRecurringPayments->CreditCardTypeId ? CreditCardType::$NameArray[$this->objRecurringPayments->CreditCardTypeId] : null;
     }
     if ($this->txtAccountNumber) {
         $this->txtAccountNumber->Text = $this->objRecurringPayments->AccountNumber;
     }
     if ($this->lblAccountNumber) {
         $this->lblAccountNumber->Text = $this->objRecurringPayments->AccountNumber;
     }
     if ($this->txtExpirationDate) {
         $this->txtExpirationDate->Text = $this->objRecurringPayments->ExpirationDate;
     }
     if ($this->lblExpirationDate) {
         $this->lblExpirationDate->Text = $this->objRecurringPayments->ExpirationDate;
     }
     if ($this->txtSecurityCode) {
         $this->txtSecurityCode->Text = $this->objRecurringPayments->SecurityCode;
     }
     if ($this->lblSecurityCode) {
         $this->lblSecurityCode->Text = $this->objRecurringPayments->SecurityCode;
     }
     if ($this->lstRecurringDonationAsRecurringPayment) {
         $this->lstRecurringDonationAsRecurringPayment->RemoveAllItems();
         $this->lstRecurringDonationAsRecurringPayment->AddItem(QApplication::Translate('- Select One -'), null);
         $objRecurringDonationArray = RecurringDonation::LoadAll();
         if ($objRecurringDonationArray) {
             foreach ($objRecurringDonationArray as $objRecurringDonation) {
                 $objListItem = new QListItem($objRecurringDonation->__toString(), $objRecurringDonation->Id);
                 if ($objRecurringDonation->RecurringPaymentId == $this->objRecurringPayments->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstRecurringDonationAsRecurringPayment->AddItem($objListItem);
             }
         }
     }
     if ($this->lblRecurringDonationAsRecurringPayment) {
         $this->lblRecurringDonationAsRecurringPayment->Text = $this->objRecurringPayments->RecurringDonationAsRecurringPayment ? $this->objRecurringPayments->RecurringDonationAsRecurringPayment->__toString() : null;
     }
 }