Esempio n. 1
0
        /// <summary>
        /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering.
        /// </summary>
        protected override void CreateChildControls()
        {
            base.CreateChildControls();
            Controls.Clear();

            var selectedNumberGuids = SelectedNumbers; //GetAttributeValue( "FilterCategories" ).SplitDelimitedValues( true ).AsGuidList();
            var definedType         = DefinedTypeCache.Get(new Guid(Rock.SystemGuid.DefinedType.COMMUNICATION_SMS_FROM));

            var smsNumbers = definedType.DefinedValues;

            if (selectedNumberGuids.Any())
            {
                smsNumbers = smsNumbers.Where(v => selectedNumberGuids.Contains(v.Guid)).ToList();
            }

            dvpFrom = new RockDropDownList();
            dvpFrom.SelectedIndex = -1;
            dvpFrom.DataSource    = smsNumbers.Select(v => new
            {
                Description = string.IsNullOrWhiteSpace(v.Description) ? v.Value : v.Description,
                v.Id
            });
            dvpFrom.DataTextField  = "Description";
            dvpFrom.DataValueField = "Id";
            dvpFrom.DataBind();

            dvpFrom.ID       = string.Format("dvpFrom_{0}", this.ID);
            dvpFrom.Label    = "From";
            dvpFrom.Help     = "The number to originate message from (configured under Admin Tools > Communications > SMS Phone Numbers).";
            dvpFrom.Required = true;
            Controls.Add(dvpFrom);

            rcwMessage       = new RockControlWrapper();
            rcwMessage.ID    = string.Format("rcwMessage_{0}", this.ID);
            rcwMessage.Label = "Message";
            rcwMessage.Help  = "<span class='tip tip-lava'></span>";
            Controls.Add(rcwMessage);

            mfpMessage    = new MergeFieldPicker();
            mfpMessage.ID = string.Format("mfpMergeFields_{0}", this.ID);
            mfpMessage.MergeFields.Clear();
            mfpMessage.MergeFields.Add("GlobalAttribute");
            mfpMessage.MergeFields.Add("Rock.Model.Person");
            mfpMessage.CssClass   += " margin-b-sm pull-right";
            mfpMessage.SelectItem += mfpMergeFields_SelectItem;
            rcwMessage.Controls.Add(mfpMessage);

            lblCount          = new Label();
            lblCount.CssClass = "badge margin-all-sm pull-right";
            lblCount.ID       = string.Format("lblCount_{0}", this.ID);
            lblCount.Visible  = this.CharacterLimit > 0;
            rcwMessage.Controls.Add(lblCount);

            tbMessage          = new RockTextBox();
            tbMessage.ID       = string.Format("tbTextMessage_{0}", this.ID);
            tbMessage.TextMode = TextBoxMode.MultiLine;
            tbMessage.Rows     = 3;
            tbMessage.Required = true;
            rcwMessage.Controls.Add(tbMessage);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <returns></returns>
        public override Control[] CreateChildControls(Type entityType, FilterField filterControl)
        {
            _ddlFilterBy          = new RockDropDownList();
            _ddlFilterBy.ID       = filterControl.ID + "_filterBy";
            _ddlFilterBy.Label    = "Filter By";
            _ddlFilterBy.Required = true;
            _ddlFilterBy.Items.Add(new ListItem("Has Course Requirement", "0"));
            _ddlFilterBy.Items.Add(new ListItem("Has Complete Course Requirement", "1"));
            _ddlFilterBy.Items.Add(new ListItem("Has Incomplete or Expired Course Requirement", "2"));
            _ddlFilterBy.Items.Add(new ListItem("Has Incomplete Course Requirement", "3"));
            _ddlFilterBy.Items.Add(new ListItem("Has Expired Course Requirement", "4"));
            filterControl.Controls.Add(_ddlFilterBy);

            _ddlCourseRequirement                = new RockDropDownList();
            _ddlCourseRequirement.ID             = filterControl.ID + "_courseRequirement";
            _ddlCourseRequirement.Label          = "Course Requirement";
            _ddlCourseRequirement.Required       = true;
            _ddlCourseRequirement.DataTextField  = "Value";
            _ddlCourseRequirement.DataValueField = "Key";
            filterControl.Controls.Add(_ddlCourseRequirement);

            RockContext rockContext = new RockContext();
            CourseRequirementService courseRequirementService = new CourseRequirementService(rockContext);
            var courseRequirements = courseRequirementService.Queryable("Group,DataView").ToList()
                                     .Where(cr => cr.IsAuthorized(Rock.Security.Authorization.VIEW, filterControl.RockBlock().CurrentPerson))
                                     .ToDictionary(k => k.Id.ToString(), v => v.Course.Name + " - " + (v.GroupId.HasValue ? v.Group.Name : "") + (v.DataViewId.HasValue ? v.DataView.Name : ""));

            _ddlCourseRequirement.DataSource = courseRequirements;
            _ddlCourseRequirement.DataBind();

            return(new Control[2] {
                _ddlFilterBy, _ddlCourseRequirement
            });
        }
Esempio n. 3
0
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <returns></returns>
        public override Control[] CreateChildControls(Type entityType, FilterField filterControl)
        {
            _ddlCourseRequirement                = new RockDropDownList();
            _ddlCourseRequirement.ID             = filterControl.ID + "_courseRequirement";
            _ddlCourseRequirement.Label          = "Course";
            _ddlCourseRequirement.Required       = true;
            _ddlCourseRequirement.DataTextField  = "Value";
            _ddlCourseRequirement.DataValueField = "Key";
            filterControl.Controls.Add(_ddlCourseRequirement);

            RockContext rockContext = new RockContext();
            CourseRequirementService courseRequirementService = new CourseRequirementService(rockContext);
            var courseRequirements = courseRequirementService.Queryable("Group,DataView").ToList()
                                     .Where(cr => cr.IsAuthorized(Rock.Security.Authorization.VIEW, filterControl.RockBlock().CurrentPerson))
                                     .ToDictionary(k => k.Id.ToString(),
                                                   v => v.Course.Name + " - " + (v.GroupId.HasValue ? v.Group.Name : "") + (v.DataViewId.HasValue ? v.DataView.Name : ""));

            _ddlCourseRequirement.DataSource = courseRequirements;
            _ddlCourseRequirement.DataBind();

            _tbDays          = new RockTextBox();
            _tbDays.Label    = "Days Until Expiration";
            _tbDays.ID       = filterControl.ID + "_tbDays";
            _tbDays.Required = true;
            filterControl.Controls.Add(_tbDays);

            _cbIncludeExpired      = new RockCheckBox();
            _cbIncludeExpired.ID   = filterControl.ID + "_cbIncludeExpired";
            _cbIncludeExpired.Text = "Include Expired";
            filterControl.Controls.Add(_cbIncludeExpired);

            return(new Control[] { _ddlCourseRequirement, _tbDays, _cbIncludeExpired });
        }
Esempio n. 4
0
        /// <summary>
        /// Handles the RowDataBound event of the gAttendees grid.
        /// </summary>
        protected void gAttendees_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                // Bind Decline Reason dropdown values.
                RockDropDownList rddlDeclineReason = e.Row.FindControl("rddlDeclineReason") as RockDropDownList;
                rddlDeclineReason.DataSource = _availableDeclineReasons;
                rddlDeclineReason.DataBind();

                RockCheckBox rcbAccept  = e.Row.FindControl("rcbAccept") as RockCheckBox;
                RockCheckBox rcbDecline = e.Row.FindControl("rcbDecline") as RockCheckBox;
                rcbAccept.InputAttributes.Add("data-paired-checkbox", rcbDecline.ClientID);
                rcbDecline.InputAttributes.Add("data-paired-checkbox", rcbAccept.ClientID);

                var rsvpData = ( RSVPAttendee )e.Row.DataItem;
                if (rsvpData.DeclineReason.HasValue)
                {
                    try
                    {
                        rddlDeclineReason.SelectedValue = rsvpData.DeclineReason.ToString();
                    }
                    catch
                    {
                        // This call may fail if the decline reason has been removed (from the DefinedType or from the individual occurrence).  Ignored.
                    }
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            gfTransactions.ApplyFilterClick   += gfTransactions_ApplyFilterClick;
            gfTransactions.ClearFilterClick   += gfTransactions_ClearFilterClick;
            gfTransactions.DisplayFilterValue += gfTransactions_DisplayFilterValue;

            SetBlockOptions();

            _canEdit = UserCanEdit;

            gTransactions.DataKeyNames      = new string[] { "Id" };
            gTransactions.Actions.ShowAdd   = _canEdit;
            gTransactions.Actions.AddClick += gTransactions_Add;
            gTransactions.GridRebind       += gTransactions_GridRebind;
            gTransactions.RowDataBound     += gTransactions_RowDataBound;
            gTransactions.IsDeleteEnabled   = _canEdit;

            // enable delete transaction
            gTransactions.Columns[gTransactions.Columns.Count - 1].Visible = true;

            int currentBatchId = PageParameter("batchId").AsInteger();

            if (_canEdit)
            {
                _ddlMove.ID             = "ddlMove";
                _ddlMove.CssClass       = "pull-left input-width-xl";
                _ddlMove.DataValueField = "Id";
                _ddlMove.DataTextField  = "Name";
                _ddlMove.DataSource     = new FinancialBatchService(new RockContext())
                                          .Queryable()
                                          .Where(b =>
                                                 b.Status == BatchStatus.Open &&
                                                 b.BatchStartDateTime.HasValue &&
                                                 b.Id != currentBatchId)
                                          .OrderBy(b => b.Name)
                                          .Select(b => new
                {
                    b.Id,
                    b.Name,
                    b.BatchStartDateTime
                })
                                          .ToList()
                                          .Select(b => new
                {
                    b.Id,
                    Name = string.Format("{0} ({1})", b.Name, b.BatchStartDateTime.Value.ToString("d"))
                })
                                          .ToList();
                _ddlMove.DataBind();
                _ddlMove.Items.Insert(0, new ListItem("-- Move Transactions To Batch --", ""));
                gTransactions.Actions.AddCustomActionControl(_ddlMove);
            }

            this.BlockUpdated += Block_BlockUpdated;
            this.AddConfigurationUpdateTrigger(upTransactions);
        }
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <returns></returns>
        public override Control[] CreateChildControls(Type entityType, FilterField filterControl)
        {
            var controls = new List <Control>();

            // Add the registration template picker
            int?selectedTemplateId = null;

            if (_ddlRegistrationTemplate != null)
            {
                selectedTemplateId = _ddlRegistrationTemplate.SelectedValueAsId();
            }

            _ddlRegistrationTemplate                = new RockDropDownList();
            _ddlRegistrationTemplate.CssClass       = "js-registration-template";
            _ddlRegistrationTemplate.ID             = filterControl.ID + "_ddlRegistrationTemplate";
            _ddlRegistrationTemplate.Label          = "Registration Template";
            _ddlRegistrationTemplate.DataTextField  = "Name";
            _ddlRegistrationTemplate.DataValueField = "Id";
            _ddlRegistrationTemplate.DataSource     = new RegistrationTemplateService(new RockContext()).Queryable()
                                                      .OrderBy(a => a.Name)
                                                      .Select(d => new
            {
                d.Id,
                d.Name
            })
                                                      .ToList();
            _ddlRegistrationTemplate.DataBind();
            _ddlRegistrationTemplate.SelectedIndexChanged += ddlRegistrationTemplate_SelectedIndexChanged;
            _ddlRegistrationTemplate.AutoPostBack          = true;
            _ddlRegistrationTemplate.SelectedValue         = selectedTemplateId.ToStringSafe();
            filterControl.Controls.Add(_ddlRegistrationTemplate);

            // Now add the registration instance picker
            _ddlRegistrationInstance          = new RockDropDownList();
            _ddlRegistrationInstance.CssClass = "js-registration-instance";
            _ddlRegistrationInstance.Label    = "Registration Instance";
            _ddlRegistrationInstance.ID       = filterControl.ID + "_ddlRegistrationInstance";
            filterControl.Controls.Add(_ddlRegistrationInstance);

            PopulateRegistrationInstanceList(_ddlRegistrationTemplate.SelectedValueAsId() ?? 0);

            _rblRegistrationType                 = new RockRadioButtonList();
            _rblRegistrationType.CssClass        = "js-registration-type";
            _rblRegistrationType.ID              = filterControl.ID + "_registrationType";
            _rblRegistrationType.RepeatDirection = RepeatDirection.Horizontal;
            _rblRegistrationType.Label           = "Person";
            _rblRegistrationType.Help            = "Choose whether to filter by the person who did the registering (registrar) or the person who was registered (registrant).";
            _rblRegistrationType.Items.Add(new ListItem("Registrar", "1"));
            _rblRegistrationType.Items.Add(new ListItem("Registrant", "2"));
            _rblRegistrationType.SelectedValue = "2";
            filterControl.Controls.Add(_rblRegistrationType);

            return(new Control[3] {
                _ddlRegistrationTemplate, _ddlRegistrationInstance, _rblRegistrationType
            });
        }
Esempio n. 7
0
        /// <summary>
        /// Binds the checkin group drop down
        /// </summary>
        /// <param name="groupType"></param>
        private void BindGroupDropDown(GroupType groupType)
        {
            EnsureChildControls();
            addButton.Visible = false;

            groupDropDownList.DataSource = GetChildGroups(groupType.Groups).ToList();
            groupDropDownList.DataBind();
            groupDropDownList.Items.Insert(0, new ListItem("", ""));
            groupDropDownList.Visible = true;
        }
Esempio n. 8
0
        /// <summary>
        /// Binds the checkin area drop down
        /// </summary>
        /// <param name="template"></param>
        private void BindGroupTypeDropDown(GroupType template)
        {
            groupDropDownList.Visible = false;

            _groupTypeOutput = new List <GroupType>();
            GetChildGroupTypes(template);

            groupTypeDropDownList.DataSource = _groupTypeOutput.Where(gt => gt.Groups.Any()).ToList();
            groupTypeDropDownList.DataBind();
            groupTypeDropDownList.Items.Insert(0, new ListItem("", ""));
            groupTypeDropDownList.Visible = true;
        }
Esempio n. 9
0
        /// <summary>
        /// Handles the RowDataBound event of the gAttendees grid.
        /// </summary>
        protected void gAttendees_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                bool isExporting = false;
                if (e is RockGridViewRowEventArgs)
                {
                    isExporting = (e as RockGridViewRowEventArgs).IsExporting;
                }

                var rsvpData = ( RSVPAttendee )e.Row.DataItem;
                if (!isExporting)
                {
                    // Bind Decline Reason dropdown values.
                    RockDropDownList rddlDeclineReason = e.Row.FindControl("rddlDeclineReason") as RockDropDownList;
                    rddlDeclineReason.DataSource = _availableDeclineReasons;
                    rddlDeclineReason.DataBind();

                    RockCheckBox rcbAccept  = e.Row.FindControl("rcbAccept") as RockCheckBox;
                    RockCheckBox rcbDecline = e.Row.FindControl("rcbDecline") as RockCheckBox;
                    rcbAccept.InputAttributes.Add("data-paired-checkbox", rcbDecline.ClientID);
                    rcbDecline.InputAttributes.Add("data-paired-checkbox", rcbAccept.ClientID);

                    if (rsvpData.DeclineReason.HasValue)
                    {
                        try
                        {
                            rddlDeclineReason.SelectedValue = rsvpData.DeclineReason.ToString();
                        }
                        catch
                        {
                            // This call may fail if the decline reason has been removed (from the DefinedType or from the individual occurrence).  Ignored.
                        }
                    }
                }
                else
                {
                    if (rsvpData.DeclineReason.HasValue)
                    {
                        var lDeclineReason = e.Row.FindControl("lDeclineReason") as Literal;
                        var declineReason  = _availableDeclineReasons.FirstOrDefault(a => a.Id == rsvpData.DeclineReason.Value);
                        if (declineReason != null)
                        {
                            lDeclineReason.Text = declineReason.Value;
                        }
                    }
                }
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Populates the template drop down.
        /// </summary>
        private void BindTemplateDropDown()
        {
            RockContext      rockContext      = new RockContext();
            GroupTypeService groupTypeService = new GroupTypeService(rockContext);

            Guid templateTypeGuid = Rock.SystemGuid.DefinedValue.GROUPTYPE_PURPOSE_CHECKIN_TEMPLATE.AsGuid();

            templateDropDownList.DataSource = groupTypeService
                                              .Queryable().AsNoTracking()
                                              .Where(t =>
                                                     t.GroupTypePurposeValue != null &&
                                                     t.GroupTypePurposeValue.Guid == templateTypeGuid)
                                              .OrderBy(t => t.Name).ToList();
            templateDropDownList.DataBind();
            templateDropDownList.Items.Insert(0, new ListItem("", ""));
        }
Esempio n. 11
0
        /// <summary>
        /// Creates the HTML controls required to configure this type of field
        /// </summary>
        /// <returns></returns>
        public override List <Control> ConfigurationControls()
        {
            var controls = base.ConfigurationControls();

            var tbValuePrompt = new RockTextBox();

            controls.Add(tbValuePrompt);
            tbValuePrompt.AutoPostBack = true;
            tbValuePrompt.TextChanged += OnQualifierUpdated;
            tbValuePrompt.Label        = "Label Prompt";
            tbValuePrompt.Help         = "The text to display as a prompt in the label textbox.";

            var ddl = new RockDropDownList();

            controls.Add(ddl);
            ddl.AutoPostBack          = true;
            ddl.SelectedIndexChanged += OnQualifierUpdated;
            ddl.DataTextField         = "Name";
            ddl.DataValueField        = "Id";
            ddl.DataSource            = new Rock.Model.DefinedTypeService(new RockContext()).Queryable().OrderBy(d => d.Order).ToList();
            ddl.DataBind();
            ddl.Items.Insert(0, new ListItem(string.Empty, string.Empty));
            ddl.Label = "Defined Type";
            ddl.Help  = "Optional Defined Type to select values from, otherwise values will be free-form text fields.";

            var tbCustomValues = new RockTextBox();

            controls.Add(tbCustomValues);
            tbCustomValues.TextMode     = TextBoxMode.MultiLine;
            tbCustomValues.Rows         = 3;
            tbCustomValues.AutoPostBack = true;
            tbCustomValues.TextChanged += OnQualifierUpdated;
            tbCustomValues.Label        = "Custom Values";
            tbCustomValues.Help         = "Optional list of options to use for the values.  Format is either 'value1,value2,value3,...', or 'value1:text1,value2:text2,value3:text3,...'.";

            var cbAllowHtml = new RockCheckBox();

            controls.Add(cbAllowHtml);

            // turn on AutoPostBack so that it'll create the Editor control based on AllowHtml
            cbAllowHtml.AutoPostBack = true;
            cbAllowHtml.Label        = "Allow Html";
            cbAllowHtml.Help         = "Allow Html content in values.";

            return(controls);
        }
Esempio n. 12
0
        /// <summary>
        /// Creates the HTML controls required to configure this type of field
        /// </summary>
        /// <returns></returns>
        public override List <Control> ConfigurationControls()
        {
            var controls = base.ConfigurationControls();

            var ddl = new RockDropDownList();

            controls.Add(ddl);
            ddl.AutoPostBack          = true;
            ddl.SelectedIndexChanged += OnQualifierUpdated;
            ddl.DataTextField         = "Name";
            ddl.DataValueField        = "Id";
            ddl.DataSource            = new Rock.Model.DefinedTypeService().Queryable().OrderBy(d => d.Order).ToList();
            ddl.DataBind();
            ddl.Items.Insert(0, new ListItem(string.Empty, string.Empty));
            ddl.Label = "Defined Type";
            ddl.Help  = "Optional Defined Type to select values from, otherwise values will be free-form text fields.";
            return(controls);
        }
Esempio n. 13
0
        /// <summary>
        /// Creates the HTML controls required to configure this type of field
        /// </summary>
        /// <returns></returns>
        public override List <Control> ConfigurationControls()
        {
            var controls = base.ConfigurationControls();

            var ddl = new RockDropDownList();

            controls.Add(ddl);
            ddl.AutoPostBack          = true;
            ddl.SelectedIndexChanged += OnQualifierUpdated;
            ddl.DataTextField         = "Name";
            ddl.DataValueField        = "Id";
            ddl.DataSource            = new BinaryFileTypeService()
                                        .Queryable()
                                        .OrderBy(f => f.Name)
                                        .Select(f => new { f.Id, f.Name })
                                        .ToList();
            ddl.DataBind();
            ddl.Items.Insert(0, new ListItem(string.Empty, string.Empty));
            ddl.Label = "File Type";
            ddl.Help  = "The type of files to list.";

            return(controls);
        }
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <returns></returns>
        public override Control[] CreateChildControls(Type entityType, FilterField filterControl)
        {
            ddlCourses = new RockDropDownList
            {
                ID             = filterControl.ID + "_ddlCourses",
                Label          = "Course",
                DataTextField  = "Name",
                DataValueField = "Id",
                Required       = true
            };
            filterControl.Controls.Add(ddlCourses);

            RockContext   rockContext   = new RockContext();
            CourseService courseService = new CourseService(rockContext);
            var           courses       = courseService.Queryable().OrderBy(c => c.Name).ToList();

            ddlCourses.DataSource = courses;
            ddlCourses.DataBind();

            return(new System.Web.UI.Control[1] {
                ddlCourses
            });
        }
Esempio n. 15
0
 private void BindRoleDropDown(GroupType newGroupType, RockDropDownList ddlRole)
 {
     ddlRole.DataSource = newGroupType.Roles;
     ddlRole.DataBind();
 }
Esempio n. 16
0
        private void DisplayAttributes()
        {
            phAttributes.Controls.Clear();

            var newGroupTypeId = ddlGroupTypes.SelectedValue.AsInteger();

            if (newGroupTypeId == 0)
            {
                pnlAttributes.Visible = false;
                return;
            }

            var attributeService = new AttributeService(rockContext);

            var groupMemberEntityId = new EntityTypeService(rockContext).Get(Rock.SystemGuid.EntityType.GROUP_MEMBER.AsGuid()).Id;
            var stringGroupTypeId   = group.GroupTypeId.ToString();

            var attributes = attributeService.Queryable()
                             .Where(a =>
                                    a.EntityTypeQualifierColumn == "GroupTypeId" &&
                                    a.EntityTypeQualifierValue == stringGroupTypeId &&
                                    a.EntityTypeId == groupMemberEntityId
                                    ).ToList();

            if (attributes.Any())
            {
                var newGroupTypeIdString = newGroupTypeId.ToString();
                var selectableAttributes = attributeService.Queryable()
                                           .Where(a =>
                                                  a.EntityTypeQualifierColumn == "GroupTypeId" &&
                                                  a.EntityTypeQualifierValue == newGroupTypeIdString &&
                                                  a.EntityTypeId == groupMemberEntityId
                                                  )
                                           .ToList()
                                           .Select(a => new
                {
                    Id   = a.Id.ToString(),
                    Name = a.Name + " [" + a.Key + "]"
                })
                                           .ToList();

                var groupIdString   = group.Id.ToString();
                var groupAttributes = attributeService.Queryable()
                                      .Where(a =>
                                             a.EntityTypeQualifierColumn == "GroupId" &&
                                             a.EntityTypeQualifierValue == groupIdString &&
                                             a.EntityTypeId == groupMemberEntityId
                                             )
                                      .ToList()
                                      .Select(a => new
                {
                    Id   = a.Id.ToString(),
                    Name = a.Name + " [" + a.Key + "]"
                })
                                      .ToList();

                selectableAttributes.AddRange(groupAttributes);


                pnlAttributes.Visible = true;
                foreach (var attribute in attributes)
                {
                    RockDropDownList ddlAttribute = new RockDropDownList()
                    {
                        ID             = attribute.Id.ToString() + "_ddlAttribute",
                        Label          = attribute.Name,
                        DataValueField = "Id",
                        DataTextField  = "Name"
                    };
                    ddlAttribute.DataSource = selectableAttributes;
                    ddlAttribute.DataBind();
                    phAttributes.Controls.Add(ddlAttribute);
                }
            }
            else
            {
                pnlAttributes.Visible = false;
            }
        }
Esempio n. 17
0
        private void BuildFees(bool setValues)
        {
            phFees.Controls.Clear();

            if (TemplateState.Fees != null && TemplateState.Fees.Any())
            {
                divFees.Visible = true;

                foreach (var fee in TemplateState.Fees.OrderBy(f => f.Order))
                {
                    var feeValues = new List <FeeInfo>();
                    if (RegistrantState.FeeValues.ContainsKey(fee.Id))
                    {
                        feeValues = RegistrantState.FeeValues[fee.Id];
                    }

                    if (fee.FeeType == RegistrationFeeType.Single)
                    {
                        string label = fee.Name;
                        var    cost  = fee.CostValue.AsDecimalOrNull();
                        if (cost.HasValue && cost.Value != 0.0M)
                        {
                            label = string.Format("{0} ({1})", fee.Name, cost.Value.FormatAsCurrency());
                        }

                        if (fee.AllowMultiple)
                        {
                            // Single Option, Multi Quantity
                            var numUpDown = new NumberUpDown();
                            numUpDown.ID      = "fee_" + fee.Id.ToString();
                            numUpDown.Label   = label;
                            numUpDown.Minimum = 0;
                            phFees.Controls.Add(numUpDown);

                            if (setValues && feeValues != null && feeValues.Any())
                            {
                                numUpDown.Value = feeValues.First().Quantity;
                            }
                        }
                        else
                        {
                            // Single Option, Single Quantity
                            var cb = new RockCheckBox();
                            cb.ID    = "fee_" + fee.Id.ToString();
                            cb.Label = label;
                            cb.SelectedIconCssClass   = "fa fa-check-square-o fa-lg";
                            cb.UnSelectedIconCssClass = "fa fa-square-o fa-lg";
                            phFees.Controls.Add(cb);

                            if (setValues && feeValues != null && feeValues.Any())
                            {
                                cb.Checked = feeValues.First().Quantity > 0;
                            }
                        }
                    }
                    else
                    {
                        // Parse the options to get name and cost for each
                        var      options    = new Dictionary <string, string>();
                        string[] nameValues = fee.CostValue.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                        foreach (string nameValue in nameValues)
                        {
                            string[] nameAndValue = nameValue.Split(new char[] { '^' }, StringSplitOptions.RemoveEmptyEntries);
                            if (nameAndValue.Length == 1)
                            {
                                options.AddOrIgnore(nameAndValue[0], nameAndValue[0]);
                            }
                            if (nameAndValue.Length == 2)
                            {
                                options.AddOrIgnore(nameAndValue[0], string.Format("{0} ({1})", nameAndValue[0], nameAndValue[1].AsDecimal().FormatAsCurrency()));
                            }
                        }

                        if (fee.AllowMultiple)
                        {
                            HtmlGenericControl feeAllowMultiple = new HtmlGenericControl("div");
                            phFees.Controls.Add(feeAllowMultiple);

                            feeAllowMultiple.AddCssClass("feetype-allowmultiples");

                            Label titleLabel = new Label();
                            feeAllowMultiple.Controls.Add(titleLabel);
                            titleLabel.CssClass = "control-label";
                            titleLabel.Text     = fee.Name;

                            foreach (var optionKeyVal in options)
                            {
                                var numUpDown = new NumberUpDown();
                                numUpDown.ID       = string.Format("fee_{0}_{1}", fee.Id, optionKeyVal.Key);
                                numUpDown.Label    = string.Format("{0}", optionKeyVal.Value);
                                numUpDown.Minimum  = 0;
                                numUpDown.CssClass = "fee-allowmultiple";
                                feeAllowMultiple.Controls.Add(numUpDown);

                                if (setValues && feeValues != null && feeValues.Any())
                                {
                                    numUpDown.Value = feeValues
                                                      .Where(f => f.Option == optionKeyVal.Key)
                                                      .Select(f => f.Quantity)
                                                      .FirstOrDefault();
                                }
                            }
                        }
                        else
                        {
                            // Multi Option, Single Quantity
                            var ddl = new RockDropDownList();
                            ddl.ID = "fee_" + fee.Id.ToString();
                            ddl.AddCssClass("input-width-md");
                            ddl.Label          = fee.Name;
                            ddl.DataValueField = "Key";
                            ddl.DataTextField  = "Value";
                            ddl.DataSource     = options;
                            ddl.DataBind();
                            ddl.Items.Insert(0, "");
                            phFees.Controls.Add(ddl);

                            if (setValues && feeValues != null && feeValues.Any())
                            {
                                ddl.SetValue(feeValues
                                             .Where(f => f.Quantity > 0)
                                             .Select(f => f.Option)
                                             .FirstOrDefault());
                            }
                        }
                    }
                }
            }
            else
            {
                divFees.Visible = false;
            }
        }
        protected void rptPartions_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                /*var ddlAttribute = ( DropDownList ) e.Item.FindControl( "ddlAttribute" );
                 * ddlAttribute.DataSource = attributes;
                 * ddlAttribute.DataTextField = "Value";
                 * ddlAttribute.DataValueField = "Key";
                 * ddlAttribute.DataBind();
                 */

                var         partition          = (( PartitionSettings )e.Item.DataItem);
                var         phPartitionControl = ( PlaceHolder )e.Item.FindControl("phPartitionControl");
                RockTextBox tbAttributeKey     = (( RockTextBox )e.Item.FindControl("tbAttributeKey"));
                switch (partition.PartitionType)
                {
                case "Campus":
                    phPartitionControl.Controls.Add(new LiteralControl("<div class='row'><div class='col-md-4'><strong>Name</strong></div><div class='col-md-8'><strong>Group</strong></div>"));

                    foreach (var campus in CampusCache.All())
                    {
                        phPartitionControl.Controls.Add(new LiteralControl("<div class='row'><div class='col-xs-4'>"));
                        var campusCbl = new CheckBox();
                        campusCbl.ID = campus.Guid.ToString() + "_" + partition.Guid + "_checkbox";
                        if (partition.PartitionValue != null)
                        {
                            campusCbl.Checked = partition.PartitionValue.Contains(campus.Guid.ToString());
                        }
                        campusCbl.Text            = campus.Name;
                        campusCbl.CheckedChanged += CampusCbl_CheckedChanged;
                        campusCbl.AutoPostBack    = true;
                        if (partition.PartitionValue != null)
                        {
                            campusCbl.Checked = partition.PartitionValue.Contains(campus.Guid.ToString());
                        }
                        phPartitionControl.Controls.Add(campusCbl);
                        phPartitionControl.Controls.Add(new LiteralControl("</div>"));

                        phPartitionControl.Controls.Add(new LiteralControl("<div class='col-xs-8'>"));
                        var ddlPlacementGroup = new RockDropDownList();
                        ddlPlacementGroup.ID = campus.Guid.ToString() + "_" + partition.Guid + "_group";
                        ddlPlacementGroup.SelectedIndexChanged += DdlPlacementGroup_SelectedIndexChanged;
                        ddlPlacementGroup.AutoPostBack          = true;
                        List <ListItem> groupList = getGroups().Select(g => new ListItem(String.Format("{0} ({1})", g.Name, g.Campus != null ? g.Campus.Name : "No Campus"), g.Id.ToString())).ToList();
                        groupList.Insert(0, new ListItem("Not Mapped", null));
                        ddlPlacementGroup.Items.AddRange(groupList.ToArray());
                        if (partition.GroupMap != null && partition.GroupMap.ContainsKey(campus.Guid.ToString()))
                        {
                            ddlPlacementGroup.SetValue(partition.GroupMap[campus.Guid.ToString()]);
                        }
                        phPartitionControl.Controls.Add(ddlPlacementGroup);
                        phPartitionControl.Controls.Add(new LiteralControl("</div></div>"));
                    }
                    phPartitionControl.Controls.Add(new LiteralControl("</div>"));
                    tbAttributeKey.ReadOnly = true;

                    break;

                case "Schedule":
                    phPartitionControl.Controls.Add(new LiteralControl("<strong>Schedule</strong><br />"));
                    var schedule = new SchedulePicker()
                    {
                        AllowMultiSelect = true, ID = partition.Guid.ToString()
                    };
                    schedule.SelectItem += Schedule_SelectItem;
                    if (!string.IsNullOrWhiteSpace(partition.PartitionValue))
                    {
                        ScheduleService scheduleService = new ScheduleService(new RockContext());
                        List <Guid>     scheduleGuids   = partition.PartitionValue.Split(',').Select(pv => pv.AsGuid()).ToList();

                        schedule.SetValues(scheduleService.GetByGuids(scheduleGuids).ToList().Select(s => s.Id).ToList());
                    }
                    phPartitionControl.Controls.Add(schedule);
                    break;

                case "DefinedType":
                    phPartitionControl.Controls.Add(new LiteralControl("<strong>Defined Type</strong><br />"));
                    var definedTypeRddl = new RockDropDownList()
                    {
                        ID = partition.Guid.ToString()
                    };
                    DefinedTypeService definedTypeService = new DefinedTypeService(new RockContext());
                    var listItems = definedTypeService.Queryable().Select(dt => new { Name = (dt.Category != null ? dt.Category.Name + ": " : "") + dt.Name, Guid = dt.Guid }).ToList();
                    listItems.Insert(0, new { Name = "Select One . . .", Guid = Guid.Empty });
                    definedTypeRddl.DataSource     = listItems;
                    definedTypeRddl.DataTextField  = "Name";
                    definedTypeRddl.DataValueField = "Guid";
                    definedTypeRddl.DataBind();
                    definedTypeRddl.AutoPostBack          = true;
                    definedTypeRddl.SelectedIndexChanged += DefinedTypeRddl_SelectedIndexChanged;
                    if (!string.IsNullOrWhiteSpace(partition.PartitionValue))
                    {
                        definedTypeRddl.SelectedValue = partition.PartitionValue;
                    }
                    phPartitionControl.Controls.Add(definedTypeRddl);
                    break;

                case "Role":
                    if (Settings.EntityTypeGuid == Rock.SystemGuid.EntityType.CONNECTION_OPPORTUNITY.AsGuid())
                    {
                        ConnectionOpportunity connection = ( ConnectionOpportunity )Settings.Entity();
                        var roles = connection.ConnectionOpportunityGroupConfigs.Where(cogc => cogc.GroupMemberRole != null).OrderBy(r => r.GroupTypeId).ThenBy(r => r.GroupMemberRole.Order).Select(r => new { Name = r.GroupType.Name + ": " + r.GroupMemberRole.Name, Guid = r.GroupMemberRole.Guid }).ToList();

                        phPartitionControl.Controls.Add(new LiteralControl("<div class='row'><div class='col-md-4'><strong>Name</strong></div><div class='col-md-8'><strong>Group</strong></div>"));

                        foreach (var role in roles)
                        {
                            phPartitionControl.Controls.Add(new LiteralControl("<div class='row'><div class='col-xs-4'>"));
                            var roleCbl = new CheckBox();
                            roleCbl.ID = role.Guid.ToString() + "_" + partition.Guid + "_checkbox";
                            if (!string.IsNullOrWhiteSpace(partition.PartitionValue))
                            {
                                roleCbl.Checked = partition.PartitionValue.Contains(role.Guid.ToString());
                            }
                            roleCbl.Text            = role.Name;
                            roleCbl.CheckedChanged += CampusCbl_CheckedChanged;
                            roleCbl.AutoPostBack    = true;
                            phPartitionControl.Controls.Add(roleCbl);
                            phPartitionControl.Controls.Add(new LiteralControl("</div>"));

                            phPartitionControl.Controls.Add(new LiteralControl("<div class='col-xs-8'>"));
                            var ddlPlacementGroup = new RockDropDownList();
                            ddlPlacementGroup.ID = role.Guid.ToString() + "_" + partition.Guid + "_group";
                            ddlPlacementGroup.SelectedIndexChanged += DdlPlacementGroup_SelectedIndexChanged;
                            ddlPlacementGroup.AutoPostBack          = true;

                            List <ListItem> groupList = getGroups().Select(g => new ListItem(String.Format("{0} ({1})", g.Name, g.Campus != null ? g.Campus.Name : "No Campus"), g.Id.ToString())).ToList();
                            groupList.Insert(0, new ListItem("Not Mapped", null));
                            ddlPlacementGroup.Items.AddRange(groupList.ToArray());
                            if (partition.GroupMap != null && partition.GroupMap.ContainsKey(role.Guid.ToString()))
                            {
                                ddlPlacementGroup.SetValue(partition.GroupMap[role.Guid.ToString()]);
                            }
                            phPartitionControl.Controls.Add(ddlPlacementGroup);
                            phPartitionControl.Controls.Add(new LiteralControl("</div></div>"));
                        }
                        phPartitionControl.Controls.Add(new LiteralControl("</div>"));
                        tbAttributeKey.ReadOnly = true;
                    }

                    break;
                }

                tbAttributeKey.ID   = "attribute_key_" + partition.Guid.ToString();
                tbAttributeKey.Text = partition.AttributeKey;
                (( LinkButton )e.Item.FindControl("bbPartitionDelete")).CommandArgument = partition.Guid.ToString();
            }
        }
Esempio n. 19
0
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <returns></returns>
        public override Control[] CreateChildControls(Type entityType, FilterField filterControl)
        {
            var controls = new List <Control>();

            var _ddlRegistrationTemplate = new RockDropDownList();

            _ddlRegistrationTemplate.CssClass       = "js-registration-template";
            _ddlRegistrationTemplate.ID             = filterControl.ID + "_ddlRegistrationTemplate";
            _ddlRegistrationTemplate.Label          = "Registration Template";
            _ddlRegistrationTemplate.DataTextField  = "Name";
            _ddlRegistrationTemplate.DataValueField = "Id";
            _ddlRegistrationTemplate.DataSource     = new RegistrationTemplateService(new RockContext()).Queryable()
                                                      .OrderBy(a => a.Name)
                                                      .Select(d => new
            {
                d.Id,
                d.Name
            })
                                                      .ToList();
            _ddlRegistrationTemplate.DataBind();
            _ddlRegistrationTemplate.SelectedIndexChanged += ddlRegistrationTemplate_SelectedIndexChanged;
            _ddlRegistrationTemplate.AutoPostBack          = true;
            filterControl.Controls.Add(_ddlRegistrationTemplate);

            // Now add the registration instance picker
            var _ddlRegistrationInstance = new RockDropDownList();

            _ddlRegistrationInstance.CssClass = "js-registration-instance";
            _ddlRegistrationInstance.Label    = "Registration Instance";
            _ddlRegistrationInstance.ID       = filterControl.ID + "_ddlRegistrationInstance";
            filterControl.Controls.Add(_ddlRegistrationInstance);

            PopulateRegistrationInstanceList(filterControl);

            var _rblRegistrationType = new RockRadioButtonList();

            _rblRegistrationType.CssClass        = "js-registration-type";
            _rblRegistrationType.ID              = filterControl.ID + "_registrationType";
            _rblRegistrationType.RepeatDirection = RepeatDirection.Horizontal;
            _rblRegistrationType.Label           = "Person";
            _rblRegistrationType.Help            = "Choose whether to filter by the person who did the registering (registrar) or the person who was registered (registrant).";
            _rblRegistrationType.Items.Add(new ListItem("Registrar", "1"));
            _rblRegistrationType.Items.Add(new ListItem("Registrant", "2"));
            _rblRegistrationType.SelectedValue = "2";
            filterControl.Controls.Add(_rblRegistrationType);

            // Add control for 'on wait list' drop down.
            RockDropDownList ddlOnWaitList = new RockDropDownList();

            ddlOnWaitList.CssClass = "js-on-wait-list";
            ddlOnWaitList.ID       = $"{filterControl.ID}_ddlOnWaitList";
            ddlOnWaitList.Label    = "On Wait List";
            ddlOnWaitList.Help     = "Select 'Yes' to only show people on the wait list. Select 'No' to only show people who are not on the wait list, or leave blank to ignore wait list status.";
            ddlOnWaitList.Items.Add(new ListItem());
            ddlOnWaitList.Items.Add(new ListItem("Yes", "True"));
            ddlOnWaitList.Items.Add(new ListItem("No", "False"));

            // Set as blank (includes both wait list and regular registrations) by default.
            ddlOnWaitList.SelectedValue = string.Empty;
            filterControl.Controls.Add(ddlOnWaitList);

            return(new Control[4] {
                _ddlRegistrationTemplate, _ddlRegistrationInstance, _rblRegistrationType, ddlOnWaitList
            });
        }
        private void ShowEdit(int savedGroupMemberId = 0)
        {
            phGroups.Controls.Clear();
            var                groups             = GetGroups();
            RockContext        rockContext        = new RockContext();
            GroupMemberService groupMemberService = new GroupMemberService(rockContext);

            foreach (var group in groups)
            {
                Panel pnlGroup = new Panel();
                phGroups.Controls.Add(pnlGroup);

                Literal ltGroup = new Literal();
                ltGroup.Text = string.Format("<h4>{0}</h4>", group.Name);
                pnlGroup.Controls.Add(ltGroup);

                var groupMembers = groupMemberService.GetByGroupIdAndPersonId(group.Id, Person.Id);
                var unusedRoles  = group.GroupType.Roles.Where(r => !groupMembers.Select(gm => gm.GroupRoleId).Contains(r.Id));

                if (unusedRoles.Any())
                {
                    Panel pnlButtonGroup = new Panel();
                    pnlButtonGroup.CssClass = "input-group";
                    pnlGroup.Controls.Add(pnlButtonGroup);

                    RockDropDownList ddlRole = new RockDropDownList();
                    ddlRole.DataSource     = unusedRoles;
                    ddlRole.DataTextField  = "Name";
                    ddlRole.DataValueField = "Id";
                    ddlRole.CssClass       = "form-control";
                    ddlRole.ID             = "ddl" + group.Id.ToString();
                    ddlRole.DataBind();
                    pnlButtonGroup.Controls.Add(ddlRole);

                    Panel pnlInputGroupButton = new Panel();
                    pnlInputGroupButton.CssClass = "input-group-btn";
                    pnlButtonGroup.Controls.Add(pnlInputGroupButton);

                    BootstrapButton btnAdd = new BootstrapButton();
                    btnAdd.Text     = "Add To Group";
                    btnAdd.CssClass = "btn btn-primary";
                    btnAdd.ID       = "Add" + group.Id.ToString();
                    btnAdd.Click   += (s, e) => { AddGroupMember(group, ddlRole); };
                    pnlInputGroupButton.Controls.Add(btnAdd);
                }

                foreach (var groupMember in groupMembers)
                {
                    Panel pnlWell = new Panel();
                    pnlWell.CssClass = "well";
                    phGroups.Controls.Add(pnlWell);

                    Literal ltRole = new Literal();
                    ltRole.Text = string.Format("<b><em>Group Role: {0}</em></b> ", groupMember.GroupRole.Name);
                    pnlWell.Controls.Add(ltRole);

                    BootstrapButton btnRemove = new BootstrapButton();
                    btnRemove.Text     = "Remove";
                    btnRemove.CssClass = "btn btn-danger btn-xs pull-right";
                    btnRemove.ID       = groupMember.Id.ToString();
                    btnRemove.Click   += (s, e) => { ConfirmDelete(groupMember.Id); };
                    pnlWell.Controls.Add(btnRemove);

                    HtmlGenericContainer hr = new HtmlGenericContainer("hr");
                    pnlWell.Controls.Add(hr);

                    groupMember.LoadAttributes();
                    var attributeList = groupMember.Attributes.Select(d => d.Value)
                                        .OrderBy(a => a.Order).ThenBy(a => a.Name).ToList();
                    foreach (var attribute in attributeList)
                    {
                        string attributeValue = groupMember.GetAttributeValue(attribute.Key);
                        attribute.AddControl(pnlWell.Controls, attributeValue, "", true, true);
                    }

                    RockTextBox tbNotes = new RockTextBox();
                    tbNotes.TextMode = TextBoxMode.MultiLine;
                    tbNotes.ID       = "Note" + groupMember.Id.ToString();
                    tbNotes.Label    = "Notes";
                    tbNotes.Text     = groupMember.Note;
                    pnlWell.Controls.Add(tbNotes);

                    if (savedGroupMemberId == groupMember.Id)
                    {
                        NotificationBox nbSavedNote = new NotificationBox();
                        nbSavedNote.Text = "Group member information saved";
                        nbSavedNote.NotificationBoxType = NotificationBoxType.Success;
                        pnlWell.Controls.Add(nbSavedNote);
                    }

                    BootstrapButton btnSave = new BootstrapButton();
                    btnSave.ID       = "save" + groupMember.Id.ToString();
                    btnSave.Text     = "Save";
                    btnSave.CssClass = "btn btn-primary btn-xs";
                    btnSave.Click   += (s, e) => { SaveGroupMember(rockContext, groupMember, pnlWell, attributeList, tbNotes); };
                    pnlWell.Controls.Add(btnSave);
                }
            }

            HtmlGenericContainer hrDone = new HtmlGenericContainer("hr");

            phGroups.Controls.Add(hrDone);

            BootstrapButton btnDone = new BootstrapButton();

            btnDone.Text   = "Done";
            btnDone.ID     = "btnDone";
            btnDone.Click += (s, e) =>
            {
                hfEditMode.Value = "0";
                ShowView();
            };
            phGroups.Controls.Add(btnDone);
        }