Exemplo n.º 1
0
        /// <summary>
        /// Raises 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);

            RockPage.AddScriptLink("~/Scripts/iscroll.js");
            RockPage.AddScriptLink("~/Scripts/CheckinClient/checkin-core.js");

            if (CurrentWorkflow == null || CurrentCheckInState == null)
            {
                NavigateToHomePage();
            }
            else
            {
                if (!Page.IsPostBack)
                {
                    ClearSelection();

                    CheckInPerson person = null;
                    CheckInGroup  group  = null;

                    person = CurrentCheckInState.CheckIn.Families.Where(f => f.Selected)
                             .SelectMany(f => f.People.Where(p => p.Selected))
                             .FirstOrDefault();

                    if (person != null)
                    {
                        group = person.GroupTypes.Where(t => t.Selected)
                                .SelectMany(t => t.Groups.Where(g => g.Selected))
                                .FirstOrDefault();
                    }

                    if (group == null)
                    {
                        GoBack();
                    }

                    lTitle.Text    = person.ToString();
                    lSubTitle.Text = group.ToString();

                    var availLocations = group.Locations.Where(l => !l.ExcludedByFilter).ToList();
                    if (availLocations.Count == 1)
                    {
                        if (UserBackedUp)
                        {
                            GoBack();
                        }
                        else
                        {
                            availLocations.FirstOrDefault().Selected = true;
                            ProcessSelection();
                        }
                    }
                    else
                    {
                        rSelection.DataSource = availLocations;
                        rSelection.DataBind();
                    }
                }
            }
        }
Exemplo n.º 2
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            RockPage.AddScriptLink("~/Scripts/iscroll.js");
            RockPage.AddScriptLink("~/Scripts/CheckinClient/checkin-core.js");

            if (CurrentWorkflow == null || CurrentCheckInState == null)
            {
                NavigateToHomePage();
            }
            else
            {
                if (!Page.IsPostBack)
                {
                    ClearSelection();

                    var availSchedules = new List <CheckInSchedule>();

                    if (CurrentCheckInType != null && CurrentCheckInType.TypeOfCheckin == TypeOfCheckin.Family)
                    {
                        CheckInFamily family = CurrentCheckInState.CheckIn.CurrentFamily;
                        if (family != null)
                        {
                            foreach (var schedule in family.GetPeople(true).SelectMany(p => p.PossibleSchedules).ToList())
                            {
                                if (!availSchedules.Any(s => s.Schedule.Id == schedule.Schedule.Id))
                                {
                                    availSchedules.Add(schedule);
                                }
                            }
                        }
                        else
                        {
                            GoBack();
                        }

                        lTitle.Text   = family.ToString();
                        lbSelect.Text = "Next";
                        lbSelect.Attributes.Add("data-loading-text", "Loading...");
                    }
                    else
                    {
                        CheckInPerson person = CurrentCheckInState.CheckIn.Families.Where(f => f.Selected)
                                               .SelectMany(f => f.People.Where(p => p.Selected))
                                               .FirstOrDefault();

                        CheckInGroup    group    = null;
                        CheckInLocation location = null;

                        if (person != null)
                        {
                            group = person.GroupTypes.Where(t => t.Selected)
                                    .SelectMany(t => t.Groups.Where(g => g.Selected))
                                    .FirstOrDefault();

                            if (group != null)
                            {
                                location = group.Locations.Where(l => l.Selected)
                                           .FirstOrDefault();
                            }
                        }

                        if (location == null)
                        {
                            GoBack();
                        }

                        lTitle.Text    = person.ToString();
                        lSubTitle.Text = string.Format("{0} - {1}", group.ToString(), location.ToString());
                        lbSelect.Text  = "Check In";
                        lbSelect.Attributes.Add("data-loading-text", "Printing...");

                        availSchedules = location.Schedules.Where(s => !s.ExcludedByFilter).ToList();
                    }

                    if (availSchedules.Count == 1)
                    {
                        availSchedules.FirstOrDefault().Selected = true;
                        ProcessSelection(maWarning);
                    }
                    else
                    {
                        string script = string.Format(@"
    <script>
        function GetTimeSelection() {{
            var ids = '';
            $('div.checkin-timelist button.active').each( function() {{
                ids += $(this).attr('schedule-id') + ',';
            }});
            if (ids == '') {{
                bootbox.alert('Please select at least one time');
                return false;
            }}
            else
            {{
                $('#{0}').button('loading')
                $('#{1}').val(ids);
                return true;
            }}
        }}
    </script>
", lbSelect.ClientID, hfTimes.ClientID);
                        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "SelectTime", script);

                        rSelection.DataSource = availSchedules
                                                .OrderBy(s => s.StartTime.Value.TimeOfDay)
                                                .ThenBy(s => s.Schedule.Name)
                                                .ToList();

                        rSelection.DataBind();
                    }
                }
            }
        }