Пример #1
0
 public function btnAdd_Click()
 {
     //Save or create all necessary objects
     // Create RecurringDonation
     if (!$this->isEdit) {
         $this->objRecurringDonation = new RecurringDonation();
         $this->objRecurringDonation->PersonId = QApplication::$PublicLogin->Person->Id;
         $this->objRecurringDonation->ConfirmationEmail = QApplication::$PublicLogin->Person->PrimaryEmail->Address;
     }
     $this->objRecurringDonation->Amount = $this->GetAmount();
     $this->objRecurringDonation->Save();
     //Create RecurringPayment object - and associate with RecurringDonation.
     if (!$this->isEdit) {
         $objRecurringPayment = new RecurringPayments();
     } else {
         $objRecurringPayment = RecurringPayments::Load($this->objRecurringDonation->RecurringPaymentId);
     }
     QCryptography::$Key = CRYPTO_KEY;
     $objCrypto = new QCryptography(null, false);
     $objRecurringPayment->Address1 = $objCrypto->Encrypt(trim($this->pnlPayment->txtAddress1->Text));
     $objRecurringPayment->Address2 = $objCrypto->Encrypt(trim($this->pnlPayment->txtAddress2->Text));
     $objRecurringPayment->City = $objCrypto->Encrypt(trim($this->pnlPayment->txtCity->Text));
     $objRecurringPayment->State = trim($this->pnlPayment->lstState->SelectedValue);
     $objRecurringPayment->Zip = $objCrypto->Encrypt(trim($this->pnlPayment->txtZipCode->Text));
     $objRecurringPayment->ExpirationDate = sprintf('%02d%02d', $this->pnlPayment->lstCcExpMonth->SelectedValue, substr($this->pnlPayment->lstCcExpYear->SelectedValue, 2));
     //$objCrypto->Encrypt(sprintf('%02d%02d', $this->pnlPayment->lstCcExpMonth->SelectedValue, substr($this->pnlPayment->lstCcExpYear->SelectedValue, 2)));
     $objRecurringPayment->SecurityCode = $objCrypto->Encrypt($this->pnlPayment->txtCcCsc->Text);
     $objRecurringPayment->CreditCardTypeId = $this->pnlPayment->lstCcType->SelectedValue;
     $objRecurringPayment->CardHolderName = $objCrypto->Encrypt(sprintf('%s %s', $this->pnlPayment->txtFirstName->Text, $this->pnlPayment->txtLastName->Text));
     $objRecurringPayment->AccountNumber = $objCrypto->Encrypt($this->pnlPayment->txtCcNumber->Text);
     $objRecurringPayment->AuthorizeFlag = $this->chkAgreement->Checked;
     $objRecurringPayment->StartDate = $this->dtxStartDate->DateTime;
     $objRecurringPayment->EndDate = $this->dtxEndDate->DateTime;
     $objRecurringPayment->Amount = $this->GetAmount();
     $objRecurringPayment->PaymentPeriodId = $this->lstPaymentPeriod->SelectedValue;
     $objRecurringPayment->Name = $this->txtPaymentName->Text;
     $intRecurringPaymentId = $objRecurringPayment->Save();
     if (!$this->isEdit) {
         $this->objRecurringDonation->RecurringPaymentId = $intRecurringPaymentId;
         $this->objRecurringDonation->Save();
     }
     // Create RecurringDonationItems - And associate with RecurringDonation
     foreach ($this->objDonationItemArray as $objDonationItem) {
         if ($objDonationItem->Amount) {
             $objOnlineDonationLineItem = clone $objDonationItem;
             $objOnlineDonationLineItem->RecurringDonationId = $this->objRecurringDonation->Id;
             $objOnlineDonationLineItem->DonationFlag = true;
             $objOnlineDonationLineItem->Save();
         }
     }
     QApplication::Redirect('/give/recurring.php');
 }
 /**
  * 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 RecurringPaymentsMetaControl
  * @param integer $intId primary key value
  * @param QMetaControlCreateType $intCreateType rules governing RecurringPayments object creation - defaults to CreateOrEdit
  * @return RecurringPaymentsMetaControl
  */
 public static function Create($objParentObject, $intId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit)
 {
     // Attempt to Load from PK Arguments
     if (strlen($intId)) {
         $objRecurringPayments = RecurringPayments::Load($intId);
         // RecurringPayments was found -- return it!
         if ($objRecurringPayments) {
             return new RecurringPaymentsMetaControl($objParentObject, $objRecurringPayments);
         } else {
             if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) {
                 throw new QCallerException('Could not find a RecurringPayments 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 RecurringPaymentsMetaControl($objParentObject, new RecurringPayments());
 }
Пример #3
0
 public static function GetSoapArrayFromArray($objArray)
 {
     if (!$objArray) {
         return null;
     }
     $objArrayToReturn = array();
     foreach ($objArray as $objObject) {
         array_push($objArrayToReturn, RecurringPayments::GetSoapObjectFromObject($objObject, true));
     }
     return unserialize(serialize($objArrayToReturn));
 }
Пример #4
0
    /**
     * Deletes all associated RecurringPaymentses
     * @return void
     */
    public function DeleteAllRecurringPaymentses()
    {
        if (is_null($this->intId)) {
            throw new QUndefinedPrimaryKeyException('Unable to call UnassociateRecurringPayments on this unsaved PaymentPeriod.');
        }
        // Get the Database Object for this Class
        $objDatabase = PaymentPeriod::GetDatabase();
        // Journaling
        if ($objDatabase->JournalingDatabase) {
            foreach (RecurringPayments::LoadArrayByPaymentPeriodId($this->intId) as $objRecurringPayments) {
                $objRecurringPayments->Journal('DELETE');
            }
        }
        // Perform the SQL Query
        $objDatabase->NonQuery('
				DELETE FROM
					`recurring_payments`
				WHERE
					`payment_period_id` = ' . $objDatabase->SqlVariable($this->intId) . '
			');
    }
 /**
  * Refresh this MetaControl with Data from the local OnlineDonation object.
  * @param boolean $blnReload reload OnlineDonation from the database
  * @return void
  */
 public function Refresh($blnReload = false)
 {
     if ($blnReload) {
         $this->objOnlineDonation->Reload();
     }
     if ($this->lblId) {
         if ($this->blnEditMode) {
             $this->lblId->Text = $this->objOnlineDonation->Id;
         }
     }
     if ($this->lstPerson) {
         $this->lstPerson->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstPerson->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objPersonArray = Person::LoadAll();
         if ($objPersonArray) {
             foreach ($objPersonArray as $objPerson) {
                 $objListItem = new QListItem($objPerson->__toString(), $objPerson->Id);
                 if ($this->objOnlineDonation->Person && $this->objOnlineDonation->Person->Id == $objPerson->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstPerson->AddItem($objListItem);
             }
         }
     }
     if ($this->lblPersonId) {
         $this->lblPersonId->Text = $this->objOnlineDonation->Person ? $this->objOnlineDonation->Person->__toString() : null;
     }
     if ($this->txtConfirmationEmail) {
         $this->txtConfirmationEmail->Text = $this->objOnlineDonation->ConfirmationEmail;
     }
     if ($this->lblConfirmationEmail) {
         $this->lblConfirmationEmail->Text = $this->objOnlineDonation->ConfirmationEmail;
     }
     if ($this->txtAmount) {
         $this->txtAmount->Text = $this->objOnlineDonation->Amount;
     }
     if ($this->lblAmount) {
         $this->lblAmount->Text = $this->objOnlineDonation->Amount;
     }
     if ($this->lstCreditCardPayment) {
         $this->lstCreditCardPayment->RemoveAllItems();
         $this->lstCreditCardPayment->AddItem(QApplication::Translate('- Select One -'), null);
         $objCreditCardPaymentArray = CreditCardPayment::LoadAll();
         if ($objCreditCardPaymentArray) {
             foreach ($objCreditCardPaymentArray as $objCreditCardPayment) {
                 $objListItem = new QListItem($objCreditCardPayment->__toString(), $objCreditCardPayment->Id);
                 if ($this->objOnlineDonation->CreditCardPayment && $this->objOnlineDonation->CreditCardPayment->Id == $objCreditCardPayment->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstCreditCardPayment->AddItem($objListItem);
             }
         }
     }
     if ($this->lblCreditCardPaymentId) {
         $this->lblCreditCardPaymentId->Text = $this->objOnlineDonation->CreditCardPayment ? $this->objOnlineDonation->CreditCardPayment->__toString() : null;
     }
     if ($this->chkIsRecurringFlag) {
         $this->chkIsRecurringFlag->Checked = $this->objOnlineDonation->IsRecurringFlag;
     }
     if ($this->lblIsRecurringFlag) {
         $this->lblIsRecurringFlag->Text = $this->objOnlineDonation->IsRecurringFlag ? QApplication::Translate('Yes') : QApplication::Translate('No');
     }
     if ($this->txtStatus) {
         $this->txtStatus->Text = $this->objOnlineDonation->Status;
     }
     if ($this->lblStatus) {
         $this->lblStatus->Text = $this->objOnlineDonation->Status;
     }
     if ($this->lstRecurringPayment) {
         $this->lstRecurringPayment->RemoveAllItems();
         $this->lstRecurringPayment->AddItem(QApplication::Translate('- Select One -'), null);
         $objRecurringPaymentArray = RecurringPayments::LoadAll();
         if ($objRecurringPaymentArray) {
             foreach ($objRecurringPaymentArray as $objRecurringPayment) {
                 $objListItem = new QListItem($objRecurringPayment->__toString(), $objRecurringPayment->Id);
                 if ($this->objOnlineDonation->RecurringPayment && $this->objOnlineDonation->RecurringPayment->Id == $objRecurringPayment->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstRecurringPayment->AddItem($objListItem);
             }
         }
     }
     if ($this->lblRecurringPaymentId) {
         $this->lblRecurringPaymentId->Text = $this->objOnlineDonation->RecurringPayment ? $this->objOnlineDonation->RecurringPayment->__toString() : null;
     }
 }
 /**
  * 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 = RecurringPayments::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 RecurringPayments, given the clauses above
     $this->DataSource = RecurringPayments::QueryArray($objCondition, $objClauses);
 }
Пример #7
0
<?php

QCryptography::$Key = CRYPTO_KEY;
$objCrypto = new QCryptography(null, false);
// iterate through all recurring payments within the time period.
$objRecurringPaymentCursor = RecurringPayments::QueryCursor(QQ::AndCondition(QQ::LessOrEqual(QQN::RecurringPayments()->StartDate, date('Y-m-d')), QQ::GreaterOrEqual(QQN::RecurringPayments()->EndDate, date('Y-m-d'))));
while ($objRecurringPayment = RecurringPayments::InstantiateCursor($objRecurringPaymentCursor)) {
    // display information..
    print sprintf("Payment of: %s within time period: %s - %s\n", $objRecurringPayment->Amount, $objRecurringPayment->StartDate, $objRecurringPayment->EndDate);
    print sprintf("name : %s\nAddress: %s %s\n City: %s\nState: %s\nZip: %s\n", $objCrypto->Decrypt($objRecurringPayment->CardHolderName), $objCrypto->Decrypt($objRecurringPayment->Address1), $objCrypto->Decrypt($objRecurringPayment->Address2), $objCrypto->Decrypt($objRecurringPayment->City), $objRecurringPayment->State, $objCrypto->Decrypt($objRecurringPayment->Zip));
    print sprintf("Account Number: %s\nExpiration Date: %s\nSecurity code: %s\n", $objCrypto->Decrypt($objRecurringPayment->AccountNumber), $objRecurringPayment->ExpirationDate, $objCrypto->Decrypt($objRecurringPayment->SecurityCode));
    print sprintf("CreditCard Type: %d\n", $objRecurringPayment->CreditCardTypeId);
    // identify if any are due today
    $startDate = $objRecurringPayment->StartDate;
    $timePeriod = 0;
    switch ($objRecurringPayment->PaymentPeriod->Id) {
        case 1:
            // weekly
            $timePeriod = 7 * 24 * 60 * 60;
            break;
        case 2:
            // bi-weekly
            $timePeriod = 2 * 7 * 24 * 60 * 60;
            break;
        case 3:
            // monthly
            $timePeriod = 30 * 24 * 60 * 60;
            break;
        case 4:
            // quarterly
            $timePeriod = 4 * 30 * 24 * 60 * 60;
 /**
  * Refresh this MetaControl with Data from the local RecurringDonation object.
  * @param boolean $blnReload reload RecurringDonation from the database
  * @return void
  */
 public function Refresh($blnReload = false)
 {
     if ($blnReload) {
         $this->objRecurringDonation->Reload();
     }
     if ($this->lblId) {
         if ($this->blnEditMode) {
             $this->lblId->Text = $this->objRecurringDonation->Id;
         }
     }
     if ($this->txtPersonId) {
         $this->txtPersonId->Text = $this->objRecurringDonation->PersonId;
     }
     if ($this->lblPersonId) {
         $this->lblPersonId->Text = $this->objRecurringDonation->PersonId;
     }
     if ($this->lstRecurringPayment) {
         $this->lstRecurringPayment->RemoveAllItems();
         $this->lstRecurringPayment->AddItem(QApplication::Translate('- Select One -'), null);
         $objRecurringPaymentArray = RecurringPayments::LoadAll();
         if ($objRecurringPaymentArray) {
             foreach ($objRecurringPaymentArray as $objRecurringPayment) {
                 $objListItem = new QListItem($objRecurringPayment->__toString(), $objRecurringPayment->Id);
                 if ($this->objRecurringDonation->RecurringPayment && $this->objRecurringDonation->RecurringPayment->Id == $objRecurringPayment->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstRecurringPayment->AddItem($objListItem);
             }
         }
     }
     if ($this->lblRecurringPaymentId) {
         $this->lblRecurringPaymentId->Text = $this->objRecurringDonation->RecurringPayment ? $this->objRecurringDonation->RecurringPayment->__toString() : null;
     }
     if ($this->txtAmount) {
         $this->txtAmount->Text = $this->objRecurringDonation->Amount;
     }
     if ($this->lblAmount) {
         $this->lblAmount->Text = $this->objRecurringDonation->Amount;
     }
     if ($this->txtConfirmationEmail) {
         $this->txtConfirmationEmail->Text = $this->objRecurringDonation->ConfirmationEmail;
     }
     if ($this->lblConfirmationEmail) {
         $this->lblConfirmationEmail->Text = $this->objRecurringDonation->ConfirmationEmail;
     }
 }
Пример #9
0
 public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects)
 {
     if ($objObject->objRecurringPayment) {
         $objObject->objRecurringPayment = RecurringPayments::GetSoapObjectFromObject($objObject->objRecurringPayment, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intRecurringPaymentId = null;
         }
     }
     return $objObject;
 }
Пример #10
0
 public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects)
 {
     if ($objObject->objPerson) {
         $objObject->objPerson = Person::GetSoapObjectFromObject($objObject->objPerson, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intPersonId = null;
         }
     }
     if ($objObject->objCreditCardPayment) {
         $objObject->objCreditCardPayment = CreditCardPayment::GetSoapObjectFromObject($objObject->objCreditCardPayment, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intCreditCardPaymentId = null;
         }
     }
     if ($objObject->objRecurringPayment) {
         $objObject->objRecurringPayment = RecurringPayments::GetSoapObjectFromObject($objObject->objRecurringPayment, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intRecurringPaymentId = null;
         }
     }
     return $objObject;
 }