/** * 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 = OnlineDonationLineItem::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 OnlineDonationLineItem, given the clauses above $this->DataSource = OnlineDonationLineItem::QueryArray($objCondition, $objClauses); }
/** * Deletes all associated OnlineDonationLineItems * @return void */ public function DeleteAllOnlineDonationLineItems() { if (is_null($this->intId)) { throw new QUndefinedPrimaryKeyException('Unable to call UnassociateOnlineDonationLineItem on this unsaved StewardshipFund.'); } // Get the Database Object for this Class $objDatabase = StewardshipFund::GetDatabase(); // Journaling if ($objDatabase->JournalingDatabase) { foreach (OnlineDonationLineItem::LoadArrayByStewardshipFundId($this->intId) as $objOnlineDonationLineItem) { $objOnlineDonationLineItem->Journal('DELETE'); } } // Perform the SQL Query $objDatabase->NonQuery(' DELETE FROM `online_donation_line_item` WHERE `stewardship_fund_id` = ' . $objDatabase->SqlVariable($this->intId) . ' '); }
protected function btnDialogSave_Click() { // GJS Save according to radio button selection switch ($this->rbtnUpdateFundSelection->SelectedValue) { case 1: if ($this->objEditing instanceof OnlineDonationLineItem) { if ($this->lstDialogFund->SelectedValue == -1) { $this->objEditing->DonationFlag = false; $this->objEditing->StewardshipFundId = null; $this->objEditing->Other = trim($this->txtDialogOther->Text); } else { $this->objEditing->DonationFlag = true; $this->objEditing->StewardshipFundId = $this->lstDialogFund->SelectedValue; $this->objEditing->Other = null; } $this->objEditing->Save(); } else { if ($this->strEditingCode == 'd') { $this->objEditing->DonationStewardshipFundId = $this->lstDialogFund->SelectedValue; $this->objEditing->Save(); } else { $this->objEditing->StewardshipFundId = $this->lstDialogFund->SelectedValue; $this->objEditing->Save(); } } break; case 2: // Save existing line Item if ($this->objEditing instanceof OnlineDonationLineItem) { if ($this->lstDialogSplitFund[0]->SelectedValue == -1) { $this->objEditing->DonationFlag = false; $this->objEditing->StewardshipFundId = null; $this->objEditing->Other = trim($this->txtDialogSplitOther[0]->Text); } else { $this->objEditing->DonationFlag = true; $this->objEditing->StewardshipFundId = $this->lstDialogSplitFund[0]->SelectedValue; $this->objEditing->Other = null; } $this->objEditing->Amount = $this->txtDialogSplitAmount[0]->Text; $this->objEditing->Save(); } else { if ($this->strEditingCode == 'd') { $this->objEditing->DonationStewardshipFundId = $this->lstDialogSplitFund[0]->SelectedValue; $this->objEditing->Amount = $this->txtDialogSplitAmount[0]->Text; $this->objEditing->Save(); } else { $this->objEditing->StewardshipFundId = $this->lstDialogSplitFund->SelectedValue; $this->objEditing->Amount = $this->txtDialogSplitAmount[0]->Text; $this->objEditing->Save(); } } // Create a new line item - Lets just make it an online donation for now $objNewLineItem = new OnlineDonationLineItem(); $objNewLineItem->Amount = $this->txtDialogSplitAmount[1]->Text; if ($this->lstDialogSplitFund[1]->SelectedValue == -1) { $objNewLineItem->DonationFlag = false; ${$objNewLineItem}->StewardshipFundId = null; $objNewLineItem->Other = trim($this->txtDialogSplitOther[1]->Text); } else { $objNewLineItem->DonationFlag = true; $objNewLineItem->StewardshipFundId = $this->lstDialogSplitFund[1]->SelectedValue; $objNewLineItem->Other = null; } $objNewLineItem->OnlineDonationId = $this->objEditing->OnlineDonationId; $objNewLineItem->Save(); break; } $this->dlgEditFund->HideDialogBox(); $this->Transactions_Refresh(); }
/** * 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 OnlineDonationLineItemMetaControl * @param integer $intId primary key value * @param QMetaControlCreateType $intCreateType rules governing OnlineDonationLineItem object creation - defaults to CreateOrEdit * @return OnlineDonationLineItemMetaControl */ public static function Create($objParentObject, $intId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) { // Attempt to Load from PK Arguments if (strlen($intId)) { $objOnlineDonationLineItem = OnlineDonationLineItem::Load($intId); // OnlineDonationLineItem was found -- return it! if ($objOnlineDonationLineItem) { return new OnlineDonationLineItemMetaControl($objParentObject, $objOnlineDonationLineItem); } else { if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) { throw new QCallerException('Could not find a OnlineDonationLineItem 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 OnlineDonationLineItemMetaControl($objParentObject, new OnlineDonationLineItem()); }
public static function GetSoapArrayFromArray($objArray) { if (!$objArray) { return null; } $objArrayToReturn = array(); foreach ($objArray as $objObject) { array_push($objArrayToReturn, OnlineDonationLineItem::GetSoapObjectFromObject($objObject, true)); } return unserialize(serialize($objArrayToReturn)); }