Beispiel #1
0
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <returns></returns>
        public override Control[] CreateChildControls(Type entityType, FilterField filterControl)
        {
            gp                  = new GroupPicker();
            gp.ID               = filterControl.ID + "_gp";
            gp.Label            = "Group(s)";
            gp.SelectItem      += gp_SelectItem;
            gp.CssClass         = "js-group-picker";
            gp.AllowMultiSelect = true;
            filterControl.Controls.Add(gp);

            cbChildGroups                 = new RockCheckBox();
            cbChildGroups.ID              = filterControl.ID + "_cbChildsGroups";
            cbChildGroups.Text            = "Include Child Group(s)";
            cbChildGroups.CssClass        = "js-include-child-groups";
            cbChildGroups.AutoPostBack    = true;
            cbChildGroups.CheckedChanged += gp_SelectItem;
            filterControl.Controls.Add(cbChildGroups);

            cbIncludeSelectedGroup                 = new RockCheckBox();
            cbIncludeSelectedGroup.ID              = filterControl.ID + "_cbIncludeSelectedGroup";
            cbIncludeSelectedGroup.Text            = "Include Selected Group(s)";
            cbIncludeSelectedGroup.CssClass        = "js-include-selected-groups";
            cbIncludeSelectedGroup.AutoPostBack    = true;
            cbIncludeSelectedGroup.CheckedChanged += gp_SelectItem;
            filterControl.Controls.Add(cbIncludeSelectedGroup);

            cbChildGroupsPlusDescendants                 = new RockCheckBox();
            cbChildGroupsPlusDescendants.ID              = filterControl.ID + "_cbChildGroupsPlusDescendants";
            cbChildGroupsPlusDescendants.Text            = "Include All Descendants(s)";
            cbChildGroupsPlusDescendants.CssClass        = "js-include-child-groups-descendants";
            cbChildGroupsPlusDescendants.AutoPostBack    = true;
            cbChildGroupsPlusDescendants.CheckedChanged += gp_SelectItem;
            filterControl.Controls.Add(cbChildGroupsPlusDescendants);

            cbIncludeInactiveGroups                 = new RockCheckBox();
            cbIncludeInactiveGroups.ID              = filterControl.ID + "_cbIncludeInactiveGroups";
            cbIncludeInactiveGroups.Text            = "Include Inactive Groups";
            cbIncludeInactiveGroups.CssClass        = "js-include-inactive-groups";
            cbIncludeInactiveGroups.AutoPostBack    = true;
            cbIncludeInactiveGroups.CheckedChanged += gp_SelectItem;
            filterControl.Controls.Add(cbIncludeInactiveGroups);

            cblRole          = new RockCheckBoxList();
            cblRole.Label    = "with Group Member Role(s) (optional)";
            cblRole.ID       = filterControl.ID + "_cblRole";
            cblRole.CssClass = "js-roles";
            cblRole.Visible  = false;
            filterControl.Controls.Add(cblRole);

            RockDropDownList ddlGroupMemberStatus = new RockDropDownList();

            ddlGroupMemberStatus.CssClass = "js-group-member-status";
            ddlGroupMemberStatus.ID       = filterControl.ID + "_ddlGroupMemberStatus";
            ddlGroupMemberStatus.Label    = "with Group Member Status";
            ddlGroupMemberStatus.Help     = "Select a specific group member status to only include group members with that status. Leaving this blank will return all members.";
            ddlGroupMemberStatus.BindToEnum <GroupMemberStatus>(true);
            ddlGroupMemberStatus.SetValue(GroupMemberStatus.Active.ConvertToInt());
            filterControl.Controls.Add(ddlGroupMemberStatus);

            PanelWidget pwAdvanced = new PanelWidget();

            filterControl.Controls.Add(pwAdvanced);
            pwAdvanced.ID       = filterControl.ID + "_pwAttributes";
            pwAdvanced.Title    = "Advanced Filters";
            pwAdvanced.CssClass = "advanced-panel";

            SlidingDateRangePicker addedOnDateRangePicker = new SlidingDateRangePicker();

            addedOnDateRangePicker.ID = pwAdvanced.ID + "_addedOnDateRangePicker";
            addedOnDateRangePicker.AddCssClass("js-dateadded-sliding-date-range");
            addedOnDateRangePicker.Label = "Date Added:";
            addedOnDateRangePicker.Help  = "Select the date range that the person was added to the group. Leaving this blank will not restrict results to a date range.";
            pwAdvanced.Controls.Add(addedOnDateRangePicker);

            SlidingDateRangePicker firstAttendanceDateRangePicker = new SlidingDateRangePicker();

            firstAttendanceDateRangePicker.ID = filterControl.ID + "_firstAttendanceDateRangePicker";
            firstAttendanceDateRangePicker.AddCssClass("js-firstattendance-sliding-date-range");
            firstAttendanceDateRangePicker.Label = "First Attendance";
            firstAttendanceDateRangePicker.Help  = "The date range of the first attendance using the 'Sunday Date' of each attendance";
            pwAdvanced.Controls.Add(firstAttendanceDateRangePicker);

            SlidingDateRangePicker lastAttendanceDateRangePicker = new SlidingDateRangePicker();

            lastAttendanceDateRangePicker.ID = filterControl.ID + "_lastAttendanceDateRangePicker";
            lastAttendanceDateRangePicker.AddCssClass("js-lastattendance-sliding-date-range");
            lastAttendanceDateRangePicker.Label = "Last Attendance";
            lastAttendanceDateRangePicker.Help  = "The date range of the last attendance using the 'Sunday Date' of each attendance";
            pwAdvanced.Controls.Add(lastAttendanceDateRangePicker);

            return(new Control[11] {
                gp, cbChildGroups, cbIncludeSelectedGroup, cbChildGroupsPlusDescendants, cblRole, ddlGroupMemberStatus, cbIncludeInactiveGroups, addedOnDateRangePicker, pwAdvanced, firstAttendanceDateRangePicker, lastAttendanceDateRangePicker
            });
        }
        /// <summary>
        /// Gets the person control for this field's <see cref="PersonFieldType"/>
        /// </summary>
        /// <param name="setValue">if set to <c>true</c> [set value].</param>
        /// <param name="fieldValue">The field value.</param>
        /// <param name="familyMemberSelected">if set to <c>true</c> [family member selected].</param>
        /// <param name="validationGroup">The validation group.</param>
        /// <returns></returns>
        public Control GetPersonControl(bool setValue, object fieldValue, bool familyMemberSelected, string validationGroup)
        {
            RegistrationTemplateFormField field = this;
            Control personFieldControl          = null;

            switch (field.PersonFieldType)
            {
            case RegistrationPersonFieldType.FirstName:
                var tbFirstName = new RockTextBox
                {
                    ID              = "tbFirstName",
                    Label           = "First Name",
                    Required        = field.IsRequired,
                    CssClass        = "js-first-name",
                    ValidationGroup = validationGroup,
                    Enabled         = !familyMemberSelected,
                    Text            = setValue && fieldValue != null?fieldValue.ToString() : string.Empty
                };

                personFieldControl = tbFirstName;
                break;

            case RegistrationPersonFieldType.LastName:
                var tbLastName = new RockTextBox
                {
                    ID              = "tbLastName",
                    Label           = "Last Name",
                    Required        = field.IsRequired,
                    ValidationGroup = validationGroup,
                    Enabled         = !familyMemberSelected,
                    Text            = setValue && fieldValue != null?fieldValue.ToString() : string.Empty
                };

                personFieldControl = tbLastName;
                break;

            case RegistrationPersonFieldType.MiddleName:
                var tbMiddleName = new RockTextBox
                {
                    ID              = "tbMiddleName",
                    Label           = "Middle Name",
                    Required        = field.IsRequired,
                    ValidationGroup = validationGroup,
                    Enabled         = !familyMemberSelected,
                    Text            = setValue && fieldValue != null?fieldValue.ToString() : string.Empty
                };

                personFieldControl = tbMiddleName;
                break;

            case RegistrationPersonFieldType.Campus:
                var cpHomeCampus = new CampusPicker
                {
                    ID               = "cpHomeCampus",
                    Label            = "Campus",
                    Required         = field.IsRequired,
                    ValidationGroup  = validationGroup,
                    Campuses         = CampusCache.All(false),
                    SelectedCampusId = setValue && fieldValue != null?fieldValue.ToString().AsIntegerOrNull() : null
                };

                personFieldControl = cpHomeCampus;
                break;

            case RegistrationPersonFieldType.Address:
                var acAddress = new AddressControl
                {
                    ID    = "acAddress",
                    Label = "Address",
                    UseStateAbbreviation   = true,
                    UseCountryAbbreviation = false,
                    Required        = field.IsRequired,
                    ValidationGroup = validationGroup
                };

                if (setValue && fieldValue != null)
                {
                    acAddress.SetValues(fieldValue as Location);
                }

                personFieldControl = acAddress;
                break;

            case RegistrationPersonFieldType.Email:
                var tbEmail = new EmailBox
                {
                    ID              = "tbEmail",
                    Label           = "Email",
                    Required        = field.IsRequired,
                    ValidationGroup = validationGroup,
                    Text            = setValue && fieldValue != null?fieldValue.ToString() : string.Empty
                };

                personFieldControl = tbEmail;
                break;

            case RegistrationPersonFieldType.Birthdate:
                var bpBirthday = new BirthdayPicker
                {
                    ID              = "bpBirthday",
                    Label           = "Birthday",
                    Required        = field.IsRequired,
                    ValidationGroup = validationGroup,
                    SelectedDate    = setValue && fieldValue != null ? fieldValue as DateTime? : null
                };

                personFieldControl = bpBirthday;
                break;

            case RegistrationPersonFieldType.Grade:
                var gpGrade = new GradePicker
                {
                    ID                    = "gpGrade",
                    Label                 = "Grade",
                    Required              = field.IsRequired,
                    ValidationGroup       = validationGroup,
                    UseAbbreviation       = true,
                    UseGradeOffsetAsValue = true,
                    CssClass              = "input-width-md"
                };

                personFieldControl = gpGrade;

                if (setValue && fieldValue != null)
                {
                    var value = fieldValue.ToString().AsIntegerOrNull();
                    gpGrade.SetValue(Person.GradeOffsetFromGraduationYear(value));
                }

                break;

            case RegistrationPersonFieldType.Gender:
                var ddlGender = new RockDropDownList
                {
                    ID              = "ddlGender",
                    Label           = "Gender",
                    Required        = field.IsRequired,
                    ValidationGroup = validationGroup,
                };

                ddlGender.BindToEnum <Gender>(true, new Gender[1] {
                    Gender.Unknown
                });

                personFieldControl = ddlGender;

                if (setValue && fieldValue != null)
                {
                    var value = fieldValue.ToString().ConvertToEnumOrNull <Gender>() ?? Gender.Unknown;
                    ddlGender.SetValue(value.ConvertToInt());
                }

                break;

            case RegistrationPersonFieldType.MaritalStatus:
                var dvpMaritalStatus = new DefinedValuePicker
                {
                    ID              = "dvpMaritalStatus",
                    Label           = "Marital Status",
                    Required        = field.IsRequired,
                    ValidationGroup = validationGroup
                };

                dvpMaritalStatus.DefinedTypeId = DefinedTypeCache.Get(Rock.SystemGuid.DefinedType.PERSON_MARITAL_STATUS.AsGuid()).Id;
                personFieldControl             = dvpMaritalStatus;

                if (setValue && fieldValue != null)
                {
                    var value = fieldValue.ToString().AsInteger();
                    dvpMaritalStatus.SetValue(value);
                }

                break;

            case RegistrationPersonFieldType.AnniversaryDate:
                var dppAnniversaryDate = new DatePartsPicker
                {
                    ID              = "dppAnniversaryDate",
                    Label           = "Anniversary Date",
                    Required        = field.IsRequired,
                    ValidationGroup = validationGroup,
                    SelectedDate    = setValue && fieldValue != null ? fieldValue as DateTime? : null
                };

                personFieldControl = dppAnniversaryDate;
                break;

            case RegistrationPersonFieldType.MobilePhone:
                var dvMobilePhone = DefinedValueCache.Get(Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_MOBILE);
                if (dvMobilePhone == null)
                {
                    break;
                }

                var ppMobile = new PhoneNumberBox
                {
                    ID              = "ppMobile",
                    Label           = dvMobilePhone.Value,
                    Required        = field.IsRequired,
                    ValidationGroup = validationGroup,
                    CountryCode     = PhoneNumber.DefaultCountryCode()
                };

                var mobilePhoneNumber = setValue && fieldValue != null ? fieldValue as PhoneNumber : null;
                ppMobile.CountryCode = mobilePhoneNumber != null ? mobilePhoneNumber.CountryCode : string.Empty;
                ppMobile.Number      = mobilePhoneNumber != null?mobilePhoneNumber.ToString() : string.Empty;

                personFieldControl = ppMobile;
                break;

            case RegistrationPersonFieldType.HomePhone:
                var dvHomePhone = DefinedValueCache.Get(Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_HOME);
                if (dvHomePhone == null)
                {
                    break;
                }

                var ppHome = new PhoneNumberBox
                {
                    ID              = "ppHome",
                    Label           = dvHomePhone.Value,
                    Required        = field.IsRequired,
                    ValidationGroup = validationGroup,
                    CountryCode     = PhoneNumber.DefaultCountryCode()
                };

                var homePhoneNumber = setValue && fieldValue != null ? fieldValue as PhoneNumber : null;
                ppHome.CountryCode = homePhoneNumber != null ? homePhoneNumber.CountryCode : string.Empty;
                ppHome.Number      = homePhoneNumber != null?homePhoneNumber.ToString() : string.Empty;

                personFieldControl = ppHome;
                break;

            case RegistrationPersonFieldType.WorkPhone:
                var dvWorkPhone = DefinedValueCache.Get(Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_WORK);
                if (dvWorkPhone == null)
                {
                    break;
                }

                var ppWork = new PhoneNumberBox
                {
                    ID              = "ppWork",
                    Label           = dvWorkPhone.Value,
                    Required        = field.IsRequired,
                    ValidationGroup = validationGroup,
                    CountryCode     = PhoneNumber.DefaultCountryCode()
                };

                var workPhoneNumber = setValue && fieldValue != null ? fieldValue as PhoneNumber : null;
                ppWork.CountryCode = workPhoneNumber != null ? workPhoneNumber.CountryCode : string.Empty;
                ppWork.Number      = workPhoneNumber != null?workPhoneNumber.ToString() : string.Empty;

                personFieldControl = ppWork;
                break;

            case RegistrationPersonFieldType.ConnectionStatus:
                var dvpConnectionStatus = new DefinedValuePicker
                {
                    ID              = "dvpConnectionStatus",
                    Label           = "Connection Status",
                    Required        = field.IsRequired,
                    ValidationGroup = validationGroup
                };

                dvpConnectionStatus.DefinedTypeId = DefinedTypeCache.Get(new Guid(Rock.SystemGuid.DefinedType.PERSON_CONNECTION_STATUS)).Id;

                if (setValue && fieldValue != null)
                {
                    var value = fieldValue.ToString().AsInteger();
                    dvpConnectionStatus.SetValue(value);
                }

                personFieldControl = dvpConnectionStatus;
                break;
            }

            return(personFieldControl);
        }
        /// <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()
        {
            Controls.Clear();

            _lblGroupTypeName = new Label();
            _lblGroupTypeName.ClientIDMode = ClientIDMode.Static;
            _lblGroupTypeName.ID           = this.ID + "_lblGroupTypeName";

            _tbGroupTypeName       = new DataTextBox();
            _tbGroupTypeName.ID    = this.ID + "_tbGroupTypeName";
            _tbGroupTypeName.Label = _rowLabel;

            // set label when they exit the edit field
            _tbGroupTypeName.Attributes["onblur"] = string.Format("javascript: $('#{0}').text($(this).val());", _lblGroupTypeName.ClientID);
            _tbGroupTypeName.SourceTypeName       = "Rock.Model.GroupType, Rock";
            _tbGroupTypeName.PropertyName         = "Name";

            _ddlGroupTypeInheritFrom       = new RockDropDownList();
            _ddlGroupTypeInheritFrom.ID    = this.ID + "_ddlGroupTypeInheritFrom";
            _ddlGroupTypeInheritFrom.Label = "Inherit from";

            _ddlGroupTypeInheritFrom.Items.Add(Rock.Constants.None.ListItem);
            var groupTypeCheckinFilterList = new GroupTypeService(new RockContext()).Queryable()
                                             //.Where( a => a.GroupTypePurposeValue.Guid == new Guid( Rock.SystemGuid.DefinedValue.GROUPTYPE_PURPOSE_CHECKIN_FILTER ) )
                                             .OrderBy(a => a.Order).ThenBy(a => a.Name)
                                             .Select(a => new { a.Id, a.Name }).ToList();

            foreach (var groupType in groupTypeCheckinFilterList)
            {
                _ddlGroupTypeInheritFrom.Items.Add(new ListItem(groupType.Name, groupType.Id.ToString()));
            }

            _ddlGroupTypeInheritFrom.AutoPostBack          = true;
            _ddlGroupTypeInheritFrom.SelectedIndexChanged += _ddlGroupTypeInheritFrom_SelectedIndexChanged;

            _phGroupTypeAttributes    = new PlaceHolder();
            _phGroupTypeAttributes.ID = this.ID + "_phGroupTypeAttributes";

            _ddlAttendanceRule       = new RockDropDownList();
            _ddlAttendanceRule.ID    = this.ID + "_ddlAttendanceRule";
            _ddlAttendanceRule.Label = "Check-in Rule";
            _ddlAttendanceRule.Help  = "The rule that check in should use when a person attempts to check in to a group of this type.  If 'None' is selected, user will not be added to group and is not required to belong to group.  If 'Add On Check In' is selected, user will be added to group if they don't already belong.  If 'Already Belongs' is selected, user must already be a member of the group or they will not be allowed to check in.";
            _ddlAttendanceRule.BindToEnum <Rock.Model.AttendanceRule>();

            _ddlPrintTo       = new RockDropDownList();
            _ddlPrintTo.ID    = this.ID + "_ddlPrintTo";
            _ddlPrintTo.Label = "Print To";
            _ddlPrintTo.Help  = "When printing check-in labels, should the device's printer or the location's printer be used?  Note: the device has a similar setting which takes precedence over this setting.";
            _ddlPrintTo.Items.Add(new ListItem("Device Printer", "1"));
            _ddlPrintTo.Items.Add(new ListItem("Location Printer", "2"));

            Controls.Add(_lblGroupTypeName);
            Controls.Add(_ddlGroupTypeInheritFrom);
            Controls.Add(_ddlAttendanceRule);
            Controls.Add(_ddlPrintTo);
            Controls.Add(_tbGroupTypeName);
            Controls.Add(_phGroupTypeAttributes);

            // Check-in Labels grid
            CreateCheckinLabelsGrid();
        }