} sendSuccessEmail($objPaymentObject->Person->Id, $objPaymentObject->Id, $objCrypto->Decrypt($objRecurringPayment->CardHolderName), $objCrypto->Decrypt($objRecurringPayment->AccountNumber), $objRecurringPayment->CreditCardTypeId, $strPaymentItems, $objRecurringPayment->Amount); // Failed! } else { // Report Message if (!$mixReturn) { print "Cannot connect to payment gateway.\n"; $status = null; $strPaymentItems = ''; } else { $objPaymentObject->Status = false; $objPaymentObject->Save(); $status = $mixReturn; print sprintf("Credit Card Processing Failed: %s\n", $mixReturn); $strPaymentItems = ''; $objDonationItems = RecurringDonationItems::LoadArrayByRecurringDonationId($objRecurringPayment->RecurringDonationAsRecurringPayment->Id); foreach ($objDonationItems as $objDonationItem) { $objFund = StewardshipFund::LoadById($objDonationItem->StewardshipFundId); $strPaymentItems .= sprintf("%s - \$%01.2f ,", $objFund->Name, $objDonationItem->Amount); } } sendFailureEmail($objPaymentObject->Person->Id, $objPaymentObject->Id, $objCrypto->Decrypt($objRecurringPayment->CardHolderName), $objRecurringPayment->CreditCardTypeId, $objCrypto->Decrypt($objRecurringPayment->AccountNumber), $strPaymentItems, $objRecurringPayment->Amount, $status); } /********************/ } else { print sprintf("Checked. And today was not : %s\n", date('Y-m-d', $checkTime)); } $checkTime += $timePeriod; } print "\n"; // create a payment entry for each one scheduled for today
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')); }
/** * Deletes all associated RecurringDonationItemses * @return void */ public function DeleteAllRecurringDonationItemses() { if (is_null($this->intId)) { throw new QUndefinedPrimaryKeyException('Unable to call UnassociateRecurringDonationItems on this unsaved RecurringDonation.'); } // Get the Database Object for this Class $objDatabase = RecurringDonation::GetDatabase(); // Journaling if ($objDatabase->JournalingDatabase) { foreach (RecurringDonationItems::LoadArrayByRecurringDonationId($this->intId) as $objRecurringDonationItems) { $objRecurringDonationItems->Journal('DELETE'); } } // Perform the SQL Query $objDatabase->NonQuery(' DELETE FROM `recurring_donation_items` WHERE `recurring_donation_id` = ' . $objDatabase->SqlVariable($this->intId) . ' '); }