Exemple #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'));
 }
 /**
  * This will save this object's RecurringPayments instance,
  * updating only the fields which have had a control created for it.
  */
 public function SaveRecurringPayments()
 {
     try {
         // Update any fields for controls that have been created
         if ($this->txtName) {
             $this->objRecurringPayments->Name = $this->txtName->Text;
         }
         if ($this->lstPaymentPeriod) {
             $this->objRecurringPayments->PaymentPeriodId = $this->lstPaymentPeriod->SelectedValue;
         }
         if ($this->txtAmount) {
             $this->objRecurringPayments->Amount = $this->txtAmount->Text;
         }
         if ($this->calStartDate) {
             $this->objRecurringPayments->StartDate = $this->calStartDate->DateTime;
         }
         if ($this->calEndDate) {
             $this->objRecurringPayments->EndDate = $this->calEndDate->DateTime;
         }
         if ($this->chkAuthorizeFlag) {
             $this->objRecurringPayments->AuthorizeFlag = $this->chkAuthorizeFlag->Checked;
         }
         if ($this->txtCardHolderName) {
             $this->objRecurringPayments->CardHolderName = $this->txtCardHolderName->Text;
         }
         if ($this->txtAddress1) {
             $this->objRecurringPayments->Address1 = $this->txtAddress1->Text;
         }
         if ($this->txtAddress2) {
             $this->objRecurringPayments->Address2 = $this->txtAddress2->Text;
         }
         if ($this->txtCity) {
             $this->objRecurringPayments->City = $this->txtCity->Text;
         }
         if ($this->txtState) {
             $this->objRecurringPayments->State = $this->txtState->Text;
         }
         if ($this->txtZip) {
             $this->objRecurringPayments->Zip = $this->txtZip->Text;
         }
         if ($this->lstCreditCardType) {
             $this->objRecurringPayments->CreditCardTypeId = $this->lstCreditCardType->SelectedValue;
         }
         if ($this->txtAccountNumber) {
             $this->objRecurringPayments->AccountNumber = $this->txtAccountNumber->Text;
         }
         if ($this->txtExpirationDate) {
             $this->objRecurringPayments->ExpirationDate = $this->txtExpirationDate->Text;
         }
         if ($this->txtSecurityCode) {
             $this->objRecurringPayments->SecurityCode = $this->txtSecurityCode->Text;
         }
         // Update any UniqueReverseReferences (if any) for controls that have been created for it
         if ($this->lstRecurringDonationAsRecurringPayment) {
             $this->objRecurringPayments->RecurringDonationAsRecurringPayment = RecurringDonation::Load($this->lstRecurringDonationAsRecurringPayment->SelectedValue);
         }
         // Save the RecurringPayments object
         $this->objRecurringPayments->Save();
         // Finally, update any ManyToManyReferences (if any)
     } catch (QCallerException $objExc) {
         $objExc->IncrementOffset();
         throw $objExc;
     }
 }
 /**
  * Reload this RecurringDonation from the database.
  * @return void
  */
 public function Reload()
 {
     // Make sure we are actually Restored from the database
     if (!$this->__blnRestored) {
         throw new QCallerException('Cannot call Reload() on a new, unsaved RecurringDonation object.');
     }
     // Reload the Object
     $objReloaded = RecurringDonation::Load($this->intId);
     // Update $this's local variables to match
     $this->intPersonId = $objReloaded->intPersonId;
     $this->RecurringPaymentId = $objReloaded->RecurringPaymentId;
     $this->fltAmount = $objReloaded->fltAmount;
     $this->strConfirmationEmail = $objReloaded->strConfirmationEmail;
 }
 /**
  * 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 RecurringDonationMetaControl
  * @param integer $intId primary key value
  * @param QMetaControlCreateType $intCreateType rules governing RecurringDonation object creation - defaults to CreateOrEdit
  * @return RecurringDonationMetaControl
  */
 public static function Create($objParentObject, $intId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit)
 {
     // Attempt to Load from PK Arguments
     if (strlen($intId)) {
         $objRecurringDonation = RecurringDonation::Load($intId);
         // RecurringDonation was found -- return it!
         if ($objRecurringDonation) {
             return new RecurringDonationMetaControl($objParentObject, $objRecurringDonation);
         } else {
             if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) {
                 throw new QCallerException('Could not find a RecurringDonation 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 RecurringDonationMetaControl($objParentObject, new RecurringDonation());
 }
 /**
  * Override method to perform a property "Get"
  * This will get the value of $strName
  *
  * @param string $strName Name of the property to get
  * @return mixed
  */
 public function __get($strName)
 {
     switch ($strName) {
         ///////////////////
         // Member Variables
         ///////////////////
         case 'Id':
             // Gets the value for intId (Read-Only PK)
             // @return integer
             return $this->intId;
         case 'RecurringDonationId':
             // Gets the value for intRecurringDonationId (Not Null)
             // @return integer
             return $this->intRecurringDonationId;
         case 'Amount':
             // Gets the value for fltAmount
             // @return double
             return $this->fltAmount;
         case 'DonationFlag':
             // Gets the value for blnDonationFlag
             // @return boolean
             return $this->blnDonationFlag;
         case 'StewardshipFundId':
             // Gets the value for intStewardshipFundId
             // @return integer
             return $this->intStewardshipFundId;
         case 'Other':
             // Gets the value for strOther
             // @return string
             return $this->strOther;
             ///////////////////
             // Member Objects
             ///////////////////
         ///////////////////
         // Member Objects
         ///////////////////
         case 'RecurringDonation':
             // Gets the value for the RecurringDonation object referenced by intRecurringDonationId (Not Null)
             // @return RecurringDonation
             try {
                 if (!$this->objRecurringDonation && !is_null($this->intRecurringDonationId)) {
                     $this->objRecurringDonation = RecurringDonation::Load($this->intRecurringDonationId);
                 }
                 return $this->objRecurringDonation;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case 'StewardshipFund':
             // Gets the value for the StewardshipFund object referenced by intStewardshipFundId
             // @return StewardshipFund
             try {
                 if (!$this->objStewardshipFund && !is_null($this->intStewardshipFundId)) {
                     $this->objStewardshipFund = StewardshipFund::Load($this->intStewardshipFundId);
                 }
                 return $this->objStewardshipFund;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
             ////////////////////////////
             // Virtual Object References (Many to Many and Reverse References)
             // (If restored via a "Many-to" expansion)
             ////////////////////////////
         ////////////////////////////
         // Virtual Object References (Many to Many and Reverse References)
         // (If restored via a "Many-to" expansion)
         ////////////////////////////
         case '__Restored':
             return $this->__blnRestored;
         default:
             try {
                 return parent::__get($strName);
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
     }
 }