/// <summary> /// Binds the filter. /// </summary> private void BindFilter() { drpDates.DelimitedValues = gfTransactions.GetUserPreference( "Date Range" ); nreAmount.DelimitedValues = gfTransactions.GetUserPreference( "Amount Range" ); tbTransactionCode.Text = gfTransactions.GetUserPreference( "Transaction Code" ); apAccount.DisplayActiveOnly = GetAttributeValue( "ActiveAccountsOnlyFilter" ).AsBoolean(); var accountIds = ( gfTransactions.GetUserPreference( "Account" ) ?? "" ).SplitDelimitedValues().AsIntegerList().Where( a => a > 0 ).ToList(); if ( accountIds.Any() ) { var service = new FinancialAccountService( new RockContext() ); var accounts = service.GetByIds( accountIds ).OrderBy( a => a.Order ).OrderBy( a => a.Name ).ToList(); apAccount.SetValues(accounts); } else { apAccount.SetValue( 0 ); } BindDefinedTypeDropdown( ddlTransactionType, new Guid( Rock.SystemGuid.DefinedType.FINANCIAL_TRANSACTION_TYPE ), "Transaction Type" ); BindDefinedTypeDropdown( ddlCurrencyType, new Guid( Rock.SystemGuid.DefinedType.FINANCIAL_CURRENCY_TYPE ), "Currency Type" ); BindDefinedTypeDropdown( ddlCreditCardType, new Guid( Rock.SystemGuid.DefinedType.FINANCIAL_CREDIT_CARD_TYPE ), "Credit Card Type" ); BindDefinedTypeDropdown( ddlSourceType, new Guid( Rock.SystemGuid.DefinedType.FINANCIAL_SOURCE_TYPE ), "Source Type" ); if ( this.ContextEntity() == null ) { var campusi = CampusCache.All(); campCampus.Campuses = campusi; campCampus.Visible = campusi.Any(); campCampus.SetValue( gfTransactions.GetUserPreference( "Campus" ) ); } else { campCampus.Visible = false; } }
/// <summary> /// Handles the filter display for each saved user value /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> /// <exception cref="System.NotImplementedException"></exception> protected void gfTransactions_DisplayFilterValue( object sender, Rock.Web.UI.Controls.GridFilter.DisplayFilterValueArgs e ) { switch ( e.Key ) { case "Row Limit": // row limit filter was removed, so hide it just in case e.Value = null; break; case "Date Range": e.Value = DateRangePicker.FormatDelimitedValues( e.Value ); break; case "Amount Range": e.Value = NumberRangeEditor.FormatDelimitedValues( e.Value, "N2" ); break; case "Account": var accountIds = e.Value.SplitDelimitedValues().AsIntegerList().Where(a => a > 0 ).ToList(); if ( accountIds.Any()) { var service = new FinancialAccountService( new RockContext() ); var accountNames = service.GetByIds( accountIds ).OrderBy( a => a.Order ).OrderBy( a => a.Name ).Select( a => a.Name ).ToList().AsDelimited( ", ", " or " ); e.Value = accountNames; } else { e.Value = string.Empty; } break; case "Transaction Type": case "Currency Type": case "Credit Card Type": case "Source Type": int definedValueId = 0; if ( int.TryParse( e.Value, out definedValueId ) ) { var definedValue = DefinedValueCache.Read( definedValueId ); if ( definedValue != null ) { e.Value = definedValue.Value; } } break; case "Campus": var campus = CampusCache.Read( e.Value.AsInteger() ); if ( campus != null ) { e.Value = campus.Name; } else { e.Value = string.Empty; } break; } }
/// <summary> /// Gfs the pledges_ display filter value. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> /// <exception cref="System.NotImplementedException"></exception> protected void gfPledges_DisplayFilterValue( object sender, GridFilter.DisplayFilterValueArgs e ) { switch ( e.Key ) { case "Date Range": if ( drpDates.Visible ) { e.Value = DateRangePicker.FormatDelimitedValues( e.Value ); } else { e.Value = string.Empty; } break; case "Last Modified": if ( drpLastModifiedDates.Visible ) { e.Value = DateRangePicker.FormatDelimitedValues( e.Value ); } else { e.Value = string.Empty; } break; case "Person": int? personId = e.Value.AsIntegerOrNull(); if ( personId != null && ppFilterPerson.Visible ) { var person = new PersonService( new RockContext() ).Get( personId.Value ); if ( person != null ) { e.Value = person.ToString(); } else { e.Value = string.Empty; } } else { e.Value = string.Empty; } break; case "Accounts": var accountIdList = e.Value.Split( ',' ).AsIntegerList(); if ( accountIdList.Any() && apFilterAccount.Visible ) { var service = new FinancialAccountService( new RockContext() ); var accounts = service.GetByIds( accountIdList ); if ( accounts != null && accounts.Any() ) { e.Value = accounts.Select( a => a.Name ).ToList().AsDelimited( "," ); } else { e.Value = string.Empty; } } else { e.Value = string.Empty; } break; default: e.Value = string.Empty; break; } }
/// <summary> /// Safely load entities that have not yet been assigned a non-null value based on the arguments. /// </summary> private void LoadEntities() { if (_automatedPaymentArgs.ScheduledTransactionId.HasValue && _financialScheduledTransaction == null) { _financialScheduledTransaction = _financialScheduledTransactionService.Queryable() .AsNoTracking() .Include(s => s.TransactionFrequencyValue) .FirstOrDefault(s => s.Id == _automatedPaymentArgs.ScheduledTransactionId.Value); } if (_authorizedPerson == null) { _authorizedPerson = _personAliasService.GetPersonNoTracking(_automatedPaymentArgs.AuthorizedPersonAliasId); } if (_financialGateway == null) { _financialGateway = _financialGatewayService.GetNoTracking(_automatedPaymentArgs.AutomatedGatewayId); } if (_financialGateway != null && _automatedGatewayComponent == null) { _automatedGatewayComponent = _financialGateway.GetGatewayComponent(); } if (_financialAccounts == null) { var accountIds = _automatedPaymentArgs.AutomatedPaymentDetails.Select(d => d.AccountId).ToList(); _financialAccounts = _financialAccountService.GetByIds(accountIds).AsNoTracking().ToDictionary(fa => fa.Id, fa => fa); } if (_authorizedPerson != null && _financialPersonSavedAccount == null && _financialGateway != null) { // Pick the correct saved account based on args or default for the user var financialGatewayId = _financialGateway.Id; var savedAccounts = _financialPersonSavedAccountService .GetByPersonId(_authorizedPerson.Id) .AsNoTracking() .Where(sa => sa.FinancialGatewayId == financialGatewayId) .Include(sa => sa.FinancialPaymentDetail) .OrderByDescending(sa => sa.CreatedDateTime ?? DateTime.MinValue) .ToList(); if (_automatedPaymentArgs.FinancialPersonSavedAccountId.HasValue) { // If there is an indicated saved account to use, don't assume any other saved account even with a schedule var savedAccountId = _automatedPaymentArgs.FinancialPersonSavedAccountId.Value; _financialPersonSavedAccount = savedAccounts.FirstOrDefault(sa => sa.Id == savedAccountId); } else { // If there is a schedule and no indicated saved account to use, try to use payment info associated with the schedule if (_financialScheduledTransaction != null) { _financialPersonSavedAccount = // sa.ReferenceNumber == fst.TransactionCode savedAccounts.FirstOrDefault(sa => !string.IsNullOrEmpty(sa.ReferenceNumber) && sa.ReferenceNumber == _financialScheduledTransaction.TransactionCode) ?? // sa.GatewayPersonIdentifier == fst.TransactionCode savedAccounts.FirstOrDefault(sa => !string.IsNullOrEmpty(sa.GatewayPersonIdentifier) && sa.GatewayPersonIdentifier == _financialScheduledTransaction.TransactionCode) ?? // sa.FinancialPaymentDetailId == fst.FinancialPaymentDetailId savedAccounts.FirstOrDefault(sa => sa.FinancialPaymentDetailId.HasValue && sa.FinancialPaymentDetailId == _financialScheduledTransaction.FinancialPaymentDetailId) ?? // sa.TransactionCode == fst.TransactionCode savedAccounts.FirstOrDefault(sa => !string.IsNullOrEmpty(sa.TransactionCode) && sa.TransactionCode == _financialScheduledTransaction.TransactionCode); } if (_financialPersonSavedAccount == null) { // Use the default or first if no default _financialPersonSavedAccount = savedAccounts.FirstOrDefault(sa => sa.IsDefault) ?? savedAccounts.FirstOrDefault(); } } } if (_financialPersonSavedAccount != null && _referencePaymentInfo == null) { _referencePaymentInfo = _financialPersonSavedAccount.GetReferencePayment(); } if (_transactionType == null) { _transactionType = DefinedValueCache.Get(_automatedPaymentArgs.TransactionTypeGuid ?? SystemGuid.DefinedValue.TRANSACTION_TYPE_CONTRIBUTION.AsGuid()); } if (_financialSource == null) { _financialSource = DefinedValueCache.Get(_automatedPaymentArgs.FinancialSourceGuid ?? SystemGuid.DefinedValue.FINANCIAL_SOURCE_TYPE_WEBSITE.AsGuid()); } }
/// <summary> /// Gfs the pledges_ display filter value. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> /// <exception cref="System.NotImplementedException"></exception> protected void gfPledges_DisplayFilterValue(object sender, GridFilter.DisplayFilterValueArgs e) { switch (e.Key) { case "Date Range": if (drpDates.Visible) { e.Value = DateRangePicker.FormatDelimitedValues(e.Value); } else { e.Value = string.Empty; } break; case "Last Modified": if (drpLastModifiedDates.Visible) { e.Value = DateRangePicker.FormatDelimitedValues(e.Value); } else { e.Value = string.Empty; } break; case "Person": int?personId = e.Value.AsIntegerOrNull(); if (personId != null && ppFilterPerson.Visible) { var person = new PersonService(new RockContext()).Get(personId.Value); if (person != null) { e.Value = person.ToString(); } else { e.Value = string.Empty; } } else { e.Value = string.Empty; } break; case "Accounts": var accountIdList = e.Value.Split(',').AsIntegerList(); if (accountIdList.Any() && apFilterAccount.Visible) { var service = new FinancialAccountService(new RockContext()); var accounts = service.GetByIds(accountIdList); if (accounts != null && accounts.Any()) { e.Value = accounts.Select(a => a.Name).ToList().AsDelimited(","); } else { e.Value = string.Empty; } } else { e.Value = string.Empty; } break; default: e.Value = string.Empty; break; } }
/// <summary> /// Gfs the pledges_ display filter value. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> /// <exception cref="System.NotImplementedException"></exception> protected void gfPledges_DisplayFilterValue(object sender, GridFilter.DisplayFilterValueArgs e) { if (AvailableAttributes != null) { var attribute = AvailableAttributes.FirstOrDefault(a => "Attribute_" + a.Key == e.Key); if (attribute != null) { try { var values = JsonConvert.DeserializeObject <List <string> >(e.Value); e.Value = attribute.FieldType.Field.FormatFilterValues(attribute.QualifierValues, values); return; } catch { // intentionally ignore } } } switch (e.Key) { case "Date Range": if (drpDates.Visible) { e.Value = DateRangePicker.FormatDelimitedValues(e.Value); } else { e.Value = string.Empty; } break; case "Last Modified": if (drpLastModifiedDates.Visible) { e.Value = DateRangePicker.FormatDelimitedValues(e.Value); } else { e.Value = string.Empty; } break; case "Person": int?personId = e.Value.AsIntegerOrNull(); if (personId != null && ppFilterPerson.Visible) { var person = new PersonService(new RockContext()).Get(personId.Value); if (person != null) { e.Value = person.ToString(); } else { e.Value = string.Empty; } } else { e.Value = string.Empty; } break; case "Accounts": var accountIdList = e.Value.Split(',').AsIntegerList(); if (accountIdList.Any() && apFilterAccount.Visible) { var service = new FinancialAccountService(new RockContext()); var accounts = service.GetByIds(accountIdList); if (accounts != null && accounts.Any()) { e.Value = accounts.Select(a => a.Name).ToList().AsDelimited(","); } else { e.Value = string.Empty; } } else { e.Value = string.Empty; } break; default: e.Value = string.Empty; break; } }