/// <summary>
        /// Handles the <see cref="E:System.Web.UI.Control.Load" /> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (!Page.IsPostBack)
            {
                if (CurrentPerson != null)
                {
                    tbFirstName.Text = CurrentPerson.FirstName;
                    tbLastName.Text  = CurrentPerson.LastName;
                    tbEmail.Text     = CurrentPerson.Email;
                    cpCampus.SetValue(CurrentPerson.GetCampus());
                }

                dtbRequest.Text = PageParameter("Request");
                cbAllowPublicDisplay.Checked = this.DefaultToPublic;
            }

            var prayerRequest = new PrayerRequest {
                Id = 0
            };

            prayerRequest.LoadAttributes();
            phAttributes.Controls.Clear();
            // Filter to only include attribute / attribute values that the person is authorized to edit.
            var excludeForEdit = prayerRequest.Attributes.Where(a => !a.Value.IsAuthorized(Authorization.EDIT, this.CurrentPerson)).Select(a => a.Key).ToList();

            Rock.Attribute.Helper.AddEditControls(prayerRequest, phAttributes, false, BlockValidationGroup, excludeForEdit);
        }
        /// <summary>
        /// Handles the <see cref="E:System.Web.UI.Control.Load" /> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (!Page.IsPostBack)
            {
                if (CurrentPerson != null)
                {
                    tbFirstName.Text = CurrentPerson.FirstName;
                    tbLastName.Text  = CurrentPerson.LastName;
                    tbEmail.Text     = CurrentPerson.Email;
                    cpCampus.SetValue(CurrentPerson.GetCampus());
                }

                dtbRequest.Text = PageParameter("Request");
                cbAllowPublicDisplay.Checked = this.DefaultToPublic;


                var prayerRequest = new PrayerRequest {
                    Id = 0
                };
                prayerRequest.LoadAttributes();
                avcEditAttributes.ExcludedAttributes = prayerRequest.Attributes.Where(a => !a.Value.IsAuthorized(Rock.Security.Authorization.EDIT, this.CurrentPerson)).Select(a => a.Value).ToArray();
                avcEditAttributes.AddEditControls(prayerRequest);
                avcEditAttributes.ValidationGroup = this.BlockValidationGroup;
            }
        }
        /// <summary>
        /// Handles the <see cref="E:System.Web.UI.Control.Load" /> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (!Page.IsPostBack)
            {
                if (CurrentPerson != null)
                {
                    tbFirstName.Text = CurrentPerson.FirstName;
                    tbLastName.Text  = CurrentPerson.LastName;
                    tbEmail.Text     = CurrentPerson.Email;
                    cpCampus.SetValue(CurrentPerson.GetCampus());
                }

                dtbRequest.Text = PageParameter("Request");
                cbAllowPublicDisplay.Checked = this.DefaultToPublic;
            }

            var prayerRequest = new PrayerRequest {
                Id = 0
            };

            prayerRequest.LoadAttributes();
            phAttributes.Controls.Clear();
            Rock.Attribute.Helper.AddEditControls(prayerRequest, phAttributes, false, BlockValidationGroup);
        }
Beispiel #4
0
        protected void LoadOpportunities()
        {
            var    currentPersonCampus = CurrentPerson.GetCampus();
            string lastAttended        = GetDiscoverAttendanceInfo(_targetPerson);
            string volunteerGroups     = GetServingInfo(_targetPerson);

            lDiscover.Text = String.Format("You attended DISCOVER My Church on {0}.", lastAttended);

            if (lastAttended == "never")
            {
                lDiscover.Text = "Upcoming DISCOVER My Church Opportunities at the " + currentPersonCampus.Name + ":<br />" + UpcomingDiscover(currentPersonCampus, "DISCOVER My Church");
            }

            lServing.Text = volunteerGroups;

            lGiving.Text = "Thanks for Giving! Your donations are making an eternal difference.  <a href= \"https://newpointe.org/GiveNow \">Click here</a> to start or manage your online giving at NewPointe - it's quick and easy!";

            lPersonInfo.Text = _targetPerson.FullName;
        }
Beispiel #5
0
        /// <summary>
        /// Fills the current person's information if it's available (e.g. passed by the person impersonation parameter)
        /// </summary>
        private void SetCurrentPersonDetails()
        {
            if (CurrentPerson == null)
            {
                return;
            }

            tbFirstName.Text = CurrentPerson.NickName;
            tbLastName.Text  = CurrentPerson.LastName;

            if (ValidateUsernameAsEmail)
            {
                tbUserName.Text = CurrentPerson.Email;
            }
            else
            {
                tbEmail.Text = CurrentPerson.Email;
            }

            switch (CurrentPerson.Gender)
            {
            case Gender.Male:
                ddlGender.SelectedValue = "M";
                break;

            case Gender.Female:
                ddlGender.SelectedValue = "F";
                break;

            default:
                ddlGender.SelectedValue = "U";
                break;
            }

            bdaypBirthDay.SelectedDate = CurrentPerson.BirthDate;

            var homeGroupTypeLocation = DefinedValueCache.Get(Rock.SystemGuid.DefinedValue.GROUP_LOCATION_TYPE_HOME);
            var familyLocation        = CurrentPerson.PrimaryFamily.GroupLocations.Where(gl => gl.IsMailingLocation && gl.GroupLocationTypeValueId == homeGroupTypeLocation.Id).OrderBy(gl => gl.Order).FirstOrDefault();

            if (familyLocation != null && familyLocation.Location != null)
            {
                acAddress.Street1    = familyLocation.Location.Street1;
                acAddress.Street2    = familyLocation.Location.Street2;
                acAddress.City       = familyLocation.Location.City;
                acAddress.County     = familyLocation.Location.County;
                acAddress.State      = familyLocation.Location.State;
                acAddress.Country    = familyLocation.Location.Country;
                acAddress.PostalCode = familyLocation.Location.PostalCode;
            }

            foreach (RepeaterItem item in rPhoneNumbers.Items)
            {
                if (item.ItemType != ListItemType.Item)
                {
                    continue;
                }

                var phoneNumberType = ( HiddenField )item.FindControl("hfPhoneType");
                var phoneNumberBox  = ( PhoneNumberBox )item.FindControl("pnbPhone");
                var cbSms           = ( CheckBox )item.FindControl("cbSms");
                var cbIsUnlisted    = ( CheckBox )item.FindControl("cbUnlisted");

                if (phoneNumberBox == null || phoneNumberType == null || phoneNumberType.Value.IsNullOrWhiteSpace())
                {
                    continue;
                }

                var phoneNumber = CurrentPerson.PhoneNumbers.FirstOrDefault(pn => pn.NumberTypeValueId.HasValue && pn.NumberTypeValueId.Value == phoneNumberType.ValueAsInt());
                if (phoneNumber == null)
                {
                    continue;
                }

                phoneNumberBox.Number      = phoneNumber.NumberFormatted;
                phoneNumberBox.CountryCode = phoneNumberBox.CountryCode;
                cbSms.Checked        = phoneNumber.IsMessagingEnabled;
                cbIsUnlisted.Checked = phoneNumber.IsUnlisted;
            }

            if (cpCampus.Visible)
            {
                cpCampus.SetValue(CurrentPerson.GetCampus());
            }
        }
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="opportunityId">The opportunity identifier.</param>
        public void ShowDetail(int opportunityId)
        {
            using (var rockContext = new RockContext())
            {
                // load campus dropdown
                var campuses = CampusCache.All();
                cpCampus.Campuses = campuses;
                cpCampus.Visible  = campuses.Count > 1;

                var opportunity = new ConnectionOpportunityService(rockContext).Get(opportunityId);
                if (opportunity == null)
                {
                    pnlSignup.Visible = false;
                    ShowError("Incorrect Opportunity Type", "The requested opportunity does not exist.");
                    return;
                }

                pnlSignup.Visible = true;

                if (!string.IsNullOrWhiteSpace(opportunity.IconCssClass))
                {
                    lIcon.Text = string.Format("<i class='{0}' ></i>", opportunity.IconCssClass);
                }

                lTitle.Text = opportunity.Name.FormatAsHtmlTitle();

                pnHome.Visible   = GetAttributeValue("DisplayHomePhone").AsBoolean();
                pnMobile.Visible = GetAttributeValue("DisplayMobilePhone").AsBoolean();

                if (CurrentPerson != null)
                {
                    tbFirstName.Text = CurrentPerson.FirstName.EncodeHtml();
                    tbLastName.Text  = CurrentPerson.LastName.EncodeHtml();
                    tbEmail.Text     = CurrentPerson.Email.EncodeHtml();

                    if (pnHome.Visible && _homePhone != null)
                    {
                        var homePhoneNumber = CurrentPerson.PhoneNumbers.Where(p => p.NumberTypeValueId == _homePhone.Id).FirstOrDefault();
                        if (homePhoneNumber != null)
                        {
                            pnHome.Number      = homePhoneNumber.NumberFormatted;
                            pnHome.CountryCode = homePhoneNumber.CountryCode;
                        }
                    }

                    if (pnMobile.Visible && _cellPhone != null)
                    {
                        var cellPhoneNumber = CurrentPerson.PhoneNumbers.Where(p => p.NumberTypeValueId == _cellPhone.Id).FirstOrDefault();
                        if (cellPhoneNumber != null)
                        {
                            pnMobile.Number      = cellPhoneNumber.NumberFormatted;
                            pnMobile.CountryCode = cellPhoneNumber.CountryCode;
                        }
                    }

                    var campus = CurrentPerson.GetCampus();
                    if (campus != null)
                    {
                        cpCampus.SelectedCampusId = campus.Id;
                    }
                }
                else
                {
                    // set the campus to the context
                    if (GetAttributeValue("EnableCampusContext").AsBoolean())
                    {
                        var campusEntityType = EntityTypeCache.Read("Rock.Model.Campus");
                        var contextCampus    = RockPage.GetCurrentContext(campusEntityType) as Campus;

                        if (contextCampus != null)
                        {
                            cpCampus.SelectedCampusId = contextCampus.Id;
                        }
                    }
                }

                // show debug info
                var mergeFields = new Dictionary <string, object>();
                mergeFields.Add("Opportunity", new ConnectionOpportunityService(rockContext).Get(PageParameter("OpportunityId").AsInteger()));
                mergeFields.Add("CurrentPerson", CurrentPerson);
                if (GetAttributeValue("EnableDebug").AsBoolean() && IsUserAuthorized(Authorization.EDIT))
                {
                    lDebug.Visible = true;
                    lDebug.Text    = mergeFields.lavaDebugInfo();
                }
            }
        }
Beispiel #7
0
        public override MobileBlock GetMobile(string parameter)
        {
            var form = new List <FormElementItem>();

            var firstName = new FormElementItem
            {
                Type     = FormElementType.Entry,
                Key      = "firstName",
                Label    = "First Name",
                Required = true
            };

            if (CurrentPerson != null)
            {
                firstName.Value = CurrentPerson.NickName;
            }
            form.Add(firstName);

            var lastName = new FormElementItem
            {
                Type     = FormElementType.Entry,
                Key      = "lastName",
                Label    = "Last Name",
                Required = GetAttributeValue("RequireLastName").AsBoolean()
            };

            if (CurrentPerson != null)
            {
                lastName.Value = CurrentPerson.LastName;
            }
            form.Add(lastName);

            var email = new FormElementItem
            {
                Type     = FormElementType.Entry,
                Key      = "email",
                Label    = "Email",
                Required = false,
                Keyboard = Keyboard.Email
            };

            if (CurrentPerson != null)
            {
                email.Value = CurrentPerson.Email;
            }
            form.Add(email);

            if (GetAttributeValue("ShowCampus").AsBoolean())
            {
                var campus = new FormElementItem
                {
                    Type     = FormElementType.Picker,
                    Key      = "campus",
                    Label    = "Campus",
                    Options  = CampusCache.All().ToDictionary(c => c.Id.ToString(), c => c.Name),
                    Required = GetAttributeValue("RequireCampus").AsBoolean()
                };
                if (CurrentPerson != null)
                {
                    campus.Value = CurrentPerson.GetCampus().Id.ToString();
                }

                form.Add(campus);
            }

            if (!string.IsNullOrWhiteSpace(GetAttributeValue("CategorySelection")))
            {
                var categoryGuid = GetAttributeValue("CategorySelection").AsGuid();
                var categoryList = CategoryCache.Read(categoryGuid).Categories.ToDictionary(c => c.Id.ToString(), c => c.Name);

                var category = new FormElementItem
                {
                    Type     = FormElementType.Picker,
                    Key      = "category",
                    Label    = "Category",
                    Options  = categoryList,
                    Required = true
                };
                form.Add(category);
            }

            var request = new FormElementItem
            {
                Type          = FormElementType.Editor,
                Label         = "Request",
                Key           = "request",
                HeightRequest = 100,
                Required      = true
            };

            form.Add(request);

            if (GetAttributeValue("EnableUrgentFlag").AsBoolean())
            {
                var urgent = new FormElementItem
                {
                    Type  = FormElementType.Switch,
                    Key   = "urgent",
                    Label = "Urgent?"
                };
                form.Add(urgent);
            }

            if (GetAttributeValue("DefaultAllowCommentsSetting").AsBoolean())
            {
                var allowComments = new FormElementItem
                {
                    Type  = FormElementType.Switch,
                    Key   = "allowComments",
                    Label = "Allow Encouraging Comments?"
                };
                form.Add(allowComments);
            }

            if (GetAttributeValue("EnablePublicDisplayFlag").AsBoolean())
            {
                var allowPublication = new FormElementItem
                {
                    Type  = FormElementType.Switch,
                    Key   = "allowPublication",
                    Label = "Allow Publication?"
                };
                form.Add(allowPublication);
            }

            var button = new FormElementItem
            {
                Type  = FormElementType.Button,
                Label = "Save Request",
                Key   = "save"
            };

            form.Add(button);

            CustomAttributes.Add("FormElementItems", JsonConvert.SerializeObject(form));
            return(new MobileBlock()
            {
                BlockType = "Avalanche.Blocks.FormBlock",
                Attributes = CustomAttributes
            });
        }
Beispiel #8
0
        protected override void OnLoad(EventArgs e)
        {
            if (!IsPostBack)
            {
                var campusCacheEnabled = CampusCache.All().AsQueryable().Where(c => c.IsActive == true).ToList();
                cpCampus.DataSource = campusCacheEnabled;
                cpCampus.DataBind();

                // Resolve the text field merge fields
                var mergeFields = Rock.Lava.LavaHelper.GetCommonMergeFields(this.RockPage, _targetPerson);
                if (_targetPerson != null)
                {
                    mergeFields.Add("Person", _targetPerson);
                }

                lPartnershipText.Text = GetAttributeValue("PartnershipText").ResolveMergeFields(mergeFields);
            }

            int ageRequirement = Convert.ToInt32(GetAttributeValue("AgeRequirement"));

            RequiredAge = GetAttributeValue("AgeRequirement");


            if (DateTime.Now.Month == 12)
            {
                CurrentYearAdd++;
                CurrentDateTime = CurrentDateTime.AddYears(CurrentYearAdd);
            }

            lYear.Text = CurrentDateTime.Year.ToString();


            if (CurrentPerson != null)
            {
                _targetPerson = CurrentPerson;
                var currentPersonCampus = CurrentPerson.GetCampus();

                if (currentPersonCampus == null)
                {
                    mdCampus.Show();
                    tbSignature.Required = false;
                }

                if (_targetPerson.Age != null)
                {
                    if (_targetPerson.Age < ageRequirement)
                    {
                        mdNotLoggedIn.Show(String.Format("Sorry, you must be at least {0} to sign the NewPointe Partnership Covenant", RequiredAge), ModalAlertType.Alert);

                        pnlSignup.Visible     = false;
                        pnlNotSixteen.Visible = true;
                        pnlSignature.Visible  = false;
                    }
                }
                else
                {
                    mdAge.Show();
                    tbSignature.Required = false;
                }

                lPersonInfo.Text = _targetPerson.FullName;
            }
            else
            {
                string path = HttpContext.Current.Request.Url.AbsolutePath;
                path = path.UrlEncode();

                mdNotLoggedIn.Show(string.Format("Before you can sign the Partnership Covenant, you must log in with your MyNewPointe account.<br /><br /> <p class=\"text-center\"><a href = \"https://newpointe.org/Login?returnurl={0} \" class=\"btn btn-newpointe\">LOG IN</a> <a href = \"https://newpointe.org/NewAccount?returnurl={0} \" class=\"btn btn-newpointe\">REGISTER</a></p>", path), ModalAlertType.Alert);

                pnlSignup.Visible      = false;
                pnlNotLoggedIn.Visible = true;
                pnlSignature.Visible   = false;
            }
        }