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 StewardshipFund.'); } // Get the Database Object for this Class $objDatabase = StewardshipFund::GetDatabase(); // Journaling if ($objDatabase->JournalingDatabase) { foreach (RecurringDonationItems::LoadArrayByStewardshipFundId($this->intId) as $objRecurringDonationItems) { $objRecurringDonationItems->Journal('DELETE'); } } // Perform the SQL Query $objDatabase->NonQuery(' DELETE FROM `recurring_donation_items` WHERE `stewardship_fund_id` = ' . $objDatabase->SqlVariable($this->intId) . ' '); }
} 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
/** * 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 = RecurringDonationItems::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 RecurringDonationItems, given the clauses above $this->DataSource = RecurringDonationItems::QueryArray($objCondition, $objClauses); }
/** * 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 RecurringDonationItemsMetaControl * @param integer $intId primary key value * @param QMetaControlCreateType $intCreateType rules governing RecurringDonationItems object creation - defaults to CreateOrEdit * @return RecurringDonationItemsMetaControl */ public static function Create($objParentObject, $intId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) { // Attempt to Load from PK Arguments if (strlen($intId)) { $objRecurringDonationItems = RecurringDonationItems::Load($intId); // RecurringDonationItems was found -- return it! if ($objRecurringDonationItems) { return new RecurringDonationItemsMetaControl($objParentObject, $objRecurringDonationItems); } else { if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) { throw new QCallerException('Could not find a RecurringDonationItems 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 RecurringDonationItemsMetaControl($objParentObject, new RecurringDonationItems()); }
public static function GetSoapArrayFromArray($objArray) { if (!$objArray) { return null; } $objArrayToReturn = array(); foreach ($objArray as $objObject) { array_push($objArrayToReturn, RecurringDonationItems::GetSoapObjectFromObject($objObject, true)); } return unserialize(serialize($objArrayToReturn)); }