protected void Page_Load(object sender, EventArgs e)
        {
            Assert.ArgumentNotNullOrEmpty(ItemPaths.SharedMemberships, "Shared club personal membership path missing");
            Assert.ArgumentNotNullOrEmpty(ItemPaths.EnquiryForm, "Enquiry form path missing");

            //get the details of the club
            currentClub = SitecoreHelper.GetCurrentClub(Sitecore.Context.Item);
            SharedLanding = new MembershipLandingItem(Sitecore.Context.Database.GetItem(ItemPaths.SharedMemberships));

            enqForm = new PageSummaryItem(Sitecore.Context.Database.GetItem(ItemPaths.EnquiryForm));

            //Databind the sections
            if (SharedLanding.InnerItem.HasChildren)
            {

                List<MembershipStaticPageItem> sections = Context.Products.ListItems.ConvertAll(X => new MembershipStaticPageItem(X));
                int counter = 1;

                sections.ForEach((delegate(MembershipStaticPageItem section)
                {
                    //section.FormUrl = EnqFormUrl;
                    if (Context.InnerItem.Fields[String.Format("Product {0} price", counter.ToString())] != null)
                    {
                        section.Price = Context.InnerItem.Fields[String.Format("Product {0} price", counter.ToString())].Value;
                        counter++;
                    }
                }));
                MemberSectionList.DataSource = sections;
                MemberSectionList.DataBind();
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                //Get club url
                club = Sitecore.Context.Database.GetItem(clubId);
                if (club != null)
                {
                    //Format Contact Address
                    System.Text.StringBuilder markupBuilder = new System.Text.StringBuilder();

                    markupBuilder.Append(club.Addressline1.Rendered != "" ? club.Addressline1.Rendered + "<br/>" : "");
                    markupBuilder.Append(club.Addressline2.Rendered != "" ? club.Addressline2.Rendered + "<br/>" : "");
                    markupBuilder.Append(club.Addressline3.Rendered != "" ? club.Addressline3.Rendered + "<br/>" : "");
                    markupBuilder.Append(club.Addressline4.Rendered != "" ? club.Addressline4.Rendered + "<br/>" : "");
                    markupBuilder.Append(club.Postcode.Rendered);

                    contactAddress = markupBuilder.ToString();
                }
                else
                {
                    Log.Error(String.Format("Error retrieving club data"), this);
                    errorMessage = String.Format("<p>{0}</p>", "Error retrieving club data");
                }
            }
            catch(Exception ex)
            {
                Log.Error(String.Format("Error retrieving club data {0}", ex.Message), this);
                errorMessage = String.Format("<p>{0}</p>", "Error retrieving club data");
                mm.virginactive.common.EmailMessagingService.ErrorEmailNotification.SendMail(ex);
            }
        }
        //public string NorthEastPoint;
        //public string SouthWestPoint;
        protected void Page_Load(object sender, EventArgs e)
        {
            var currentItem = Sitecore.Context.Item;
            LocationItem location = new LocationItem(currentItem);

            var containerItem = currentItem.Parent.Parent;
            ClubMicrositeLandingItem landing = new ClubMicrositeLandingItem(containerItem);

            Sitecore.Data.Items.Item activeClubItem = landing.Club.Item;

            ActiveClub = new ClubItem(activeClubItem);

            double lat = 0;
            double lng = 0;
            double distance = 10;
            int zoom = 10;

            double.TryParse(ActiveClub.Lat.Rendered, out lat);
            double.TryParse(ActiveClub.Long.Rendered, out lng);
            double.TryParse(location.Findclubsrange.Rendered, out distance);
            int.TryParse(location.Zoomlevel.Rendered, out ZoomLevel);

            //NorthEastPoint = location.NorthEastpoint.Rendered;
            //SouthWestPoint = location.SoutWestpoint.Rendered;

            List<Club> clubs = ClubUtil.GetNearestClubsInRange(lat, lng, distance).Where(x => x.ClubItm.InnerItem.ID != ActiveClub.InnerItem.ID).ToList();

            ClubRepeater.DataSource = clubs;
            ClubRepeater.DataBind();
        }
        /// <summary>
        /// Set the Manager object from club
        /// </summary>
        /// <param name="clubItem">The club where manager needs to be looked at</param>
        private void SetManager(ClubItem clubItem)
        {
            if (clubItem != null)
            {
                //get managers info
                List<ManagerItem> staffMembers = null;
                if (clubItem.InnerItem.Axes.SelectItems(String.Format("descendant-or-self::*[@@tid = '{0}']", ManagerItem.TemplateId)) != null)
                {
                    staffMembers = clubItem.InnerItem.Axes.SelectItems(String.Format("descendant-or-self::*[@@tid = '{0}']", ManagerItem.TemplateId)).ToList().ConvertAll(x => new ManagerItem(x));

                    manager = staffMembers.First();
                }

                //If manager found than set the properties.
                if (manager != null)
                {
                    string name = manager.Person.Firstname.Rendered + " " + manager.Person.Lastname.Rendered;
                    ManagerImageURL = manager.Person.Profileimage.RenderCrop("160x160");

                    String whatNextText = currentItem.WhatsNextBodytext.Rendered.Replace("##ManagerName##", manager.Person.Firstname.Rendered);
                    whatNextText = whatNextText.Replace("##Club##", clubItem.Clubname.Rendered);
                    whatNextText = whatNextText.Replace("##ClubPhone##", clubItem.Salestelephonenumber.Rendered);
                    whatNextText = whatNextText.Replace("##ManagerFullName##", name);

                    ltText.Text = whatNextText;
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            ClubFacilitiesLandingItem context = new ClubFacilitiesLandingItem(Sitecore.Context.Item);
            club = SitecoreHelper.GetCurrentClub(context.InnerItem);

            List<string> sharedFacilities = context.SharedFacilites.Raw.Split('|').ToList();
            List<FacilityItem> clubSpecificFacilities = new List<FacilityItem>();
            if (context.InnerItem.HasChildren)
            {
                clubSpecificFacilities = context.InnerItem.Children.ToList().ConvertAll(X => new FacilityItem(X));
            }

            //Fetch all the facility lists
            List<FacilitiesListingItem> facilityLists = Sitecore.Context.Database.GetItem(ItemPaths.SharedFacilities).Children.ToList().ConvertAll(X => new FacilitiesListingItem(X));
            //facilityLists.RemoveAll(x => x.PageSummary.Hidefrommenu.Checked);

            List<FacilitiesListingItem> facilityListsToRemove = new List<FacilitiesListingItem>();

            facilityLists.ForEach(delegate(FacilitiesListingItem fac)
            {
                //Intially set FacilityList of each facility type to all shared facilities
                fac.FacilityList = fac.InnerItem.Children.ToList().ConvertAll(Y => new FacilityModuleItem(Y));
                //weed out all the shared facilities that are not available in this club
                fac.FacilityList = (from facItem in fac.FacilityList
                                    where sharedFacilities.Contains(facItem.InnerItem.ID.ToString())
                                    select facItem).ToList();

                //Include any club specific facilities
                if (clubSpecificFacilities.Count > 0)
                {
                    List<FacilityItem> facItemsToRemove = new List<FacilityItem>();
                    clubSpecificFacilities.ForEach(delegate(FacilityItem clubSpecificFac)
                    {
                        if (clubSpecificFac.FacilityArea.Raw == fac.InnerItem.ID.ToString())
                        {
                            fac.FacilityList.Insert(0,clubSpecificFac.FacilityModule); //Add the club specific facilities to top of lists
                            facItemsToRemove.Add(clubSpecificFac);
                        }
                    });
                    clubSpecificFacilities.RemoveAll(X => facItemsToRemove.Contains(X)); //Remove the club specific facilities we have already added
                }

                //Remove any un-used facility types
                if (fac.FacilityList.Count == 0)
                    facilityListsToRemove.Add(fac);
            });

            //Remove any un-used facility types
            facilityLists.RemoveAll(X => facilityListsToRemove.Contains(X));

            FacilityListing.DataSource = facilityLists;
            FacilityListing.DataBind();
            JumpLinkList.DataSource = facilityLists;
            JumpLinkList.DataBind();
        }
        private void SetSitecoreData()
        {
            //clubId = WebUtil.GetQueryString("_clubid");
            //profile = WebUtil.GetQueryString("_profile");

            //Get User from Session
            //Check Session
            User objUser = new User();
            if (Session["sess_User_landing"] != null)
            {
                objUser = (User)Session["sess_User_landing"];

                clubId = objUser.BrowsingHistory.LandingClubID;
                profile = objUser.BrowsingHistory.LandingProfile;
                region = objUser.BrowsingHistory.LandingRegion;
            }

            //Get Club Data

            if (!String.IsNullOrEmpty(clubId))
                clubItem = SitecoreHelper.GetClubOnClubId(clubId);

            if (clubItem != null)
            {
                //Get Personal Membership Item
                MembershipListingItem membership = clubItem.InnerItem.Axes.SelectSingleItem(String.Format(@"descendant::*[@@tid = '{0}']", MembershipListingItem.TemplateId));

                if (membership != null)
                {
                    membershipTeaser = membership.MembershipTeaser.Rendered;
                }

                //ltButtonText.Text = String.Format(ltButtonText.Text, "in " + clubItem.Clubname.Rendered + " ");
                //ltCallToAction.Text = String.Format(ltCallToAction.Text, clubItem.Clubname.Rendered + " ");
            }

            if (!String.IsNullOrEmpty(profile))
            {
                //Get Profile Landing Data
                currentLanding = SitecoreHelper.GetContextLandingItem(currentItem, profile);
            }
            else
            {
                currentLanding = currentItem.InnerItem.Axes.SelectSingleItem(String.Format("ancestor-or-self::*[@@tid='{0}']", LandingPageItem.TemplateId));
            }

            HtmlGenericControl BodyTag = (HtmlGenericControl)this.Page.FindControl("BodyTag");
            BodyTag.Attributes.Add("data-landing", currentItem.ID.ToShortID().ToString());
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            BindDropDownLists();

            try
            {
                currentClub = SitecoreHelper.GetCurrentClub(feedbackItem.InnerItem);

                //Find Club Kids manager (first person in the list of KidsStaff
                try
                {
                    manager = new KidsStaffItem(feedbackItem.InnerItem.Axes.SelectItems(String.Format("../descendant::*[@@tid='{0}']", KidsStaffItem.TemplateId))[0]);
                    branchManager = new ManagerItem(feedbackItem.InnerItem.Axes.SelectItems(String.Format("../descendant::*[@@tid='{0}']", ManagerItem.TemplateId))[0]);
                    if (manager != null)
                    {
                        ManagerPanel.Visible = true;
                    }
                }
                catch (Exception exe)
                {
                    Log.Error(String.Format("Could not fetch a club manager for club {1}: {0}", exe.Message, currentClub.Clubname.Raw), this);
                    mm.virginactive.common.EmailMessagingService.ErrorEmailNotification.SendMail(exe);
                }

                string val = Translate.Text("Please enter {0}");
                rfvName.ErrorMessage = String.Format("<div class='error-msg'><p>{0}</p></div>", String.Format(val, Translate.Text("a name")));
                revName.ErrorMessage = String.Format("<div class='error-msg'><p>{0}</p></div>", String.Format(val, Translate.Text("a valid name")));
                rfvEmail.ErrorMessage = String.Format("<div class='error-msg'><p>{0}</p></div>", String.Format(val, Translate.Text("an email address")));
                revEmail.ErrorMessage = String.Format("<div class='error-msg'><p>{0}</p></div>", String.Format(val, Translate.Text("a valid email address")));
                rfvPhone.ErrorMessage = String.Format("<div class='error-msg'><p>{0}</p></div>", String.Format(val, Translate.Text("a phone number")));
                revPhone.ErrorMessage = String.Format("<div class='error-msg'><p>{0}</p></div>", String.Format(val, Translate.Text("a valid phone number")));
                rfvComments.ErrorMessage = String.Format("<div class='error-msg'><p>{0}</p></div>", String.Format(val, Translate.Text("your comments")));
                revEmail.ValidationExpression = Settings.EmailAddressRegularExpression;
                revPhone.ValidationExpression = Settings.PhoneNumberRegularExpression;
                revName.ValidationExpression = Settings.NameRegularExpression;

            }
            catch (Exception ex)
            {
                Log.Error(String.Format("Error generating Club feedback form items: {0}", ex.Message), this);
                mm.virginactive.common.EmailMessagingService.ErrorEmailNotification.SendMail(ex);
            }

            this.Page.FindControl("ScriptPh").Controls.Add(new LiteralControl(@"<script>
                $(function(){
                    $.va_init.functions.setupForms();
                });
                </script>"));
        }
Exemple #8
0
        public ClubList GetAll()
        {
            var clubs           = _clubRepository.GetAll().ToList();
            var gameProcessList = new ClubList();

            foreach (var club in clubs)
            {
                var clubItem = new ClubItem
                {
                    Id   = club.Id,
                    Name = club.Name
                };

                var gameProcesses = _gameProcessRepository.GetAll().Where(c => c.ClubId == club.Id).ToList();

                foreach (var gameProcess in gameProcesses)
                {
                    var gameProcessItems = GetGameProcessItems(gameProcess);

                    var totalInput  = gameProcessItems.SelectMany(c => c.Input.Select(i => i.Amount).ToList()).Sum();
                    var totalOutput = gameProcessItems.Where(c => c.OutPut != null).Select(c => c.OutPut.Amount).Sum();

                    var subtract = !gameProcess.EndDateTime.HasValue
                        ? DateTime.Subtract(gameProcess.StartDateTime.GetValueOrDefault())
                        : gameProcess.EndDateTime.Value.Subtract(gameProcess.StartDateTime.GetValueOrDefault());

                    var item = new GameProcessListItem
                    {
                        Id           = gameProcess.Id,
                        DateTime     = gameProcess.StartDateTime.GetValueOrDefault(),
                        DirationTime = subtract,
                        PlayerCount  = gameProcessItems.Count,
                        TotalInput   = totalInput,
                        TotalOutput  = totalOutput,
                        Total        = (totalInput - totalOutput),
                        IsFinish     = gameProcess.EndDateTime.HasValue
                    };
                    clubItem.Items.Add(item);
                }

                clubItem.PlayersCount = clubItem.Items.Sum(c => c.PlayerCount);
                clubItem.Total        = clubItem.Items.Sum(c => c.Total);

                gameProcessList.Clubs.Add(clubItem);
            }

            return(gameProcessList);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //get the details of the club
            ClubItem currentClub = new ClubItem(Sitecore.Context.Item.Axes.SelectSingleItem(String.Format(@"ancestor-or-self::*[@@tid=""{0}"" or @@tid=""{1}""]", ClassicClubItem.TemplateId, LifeCentreItem.TemplateId)));

            if (currentClub.GetCrmSystem() == ClubCrmSystemTypes.ClubCentric)
            {
                //Load the download timetable area
                ClubTimetable clubTimetable = Page.LoadControl("~/layouts/virginactive/club/ClubFeedback.ascx") as ClubTimetable;
                PagePh.Controls.Add(clubTimetable);
            }
            else
            {
                //Load rendered time tables
                ClubTimeTableDownload clubTimetableDownload = Page.LoadControl("~/layouts/virginactive/club/ClubKidsFeedback.ascx") as ClubTimeTableDownload;
                PagePh.Controls.Add(clubTimetableDownload);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                Item landingItem =
                    Sitecore.Context.Item.Axes.SelectSingleItem(String.Format("ancestor-or-self::*[@@tid='{0}']",
                                                                              ClubMicrositeLandingItem.TemplateId));

                if (landingItem == null)
                {
                    return;
                }

                Item homeItem =
                    landingItem.Axes.SelectSingleItem(String.Format("*[@@tid='{0}']", MicrositeHomeItem.TemplateId));

                if (homeItem == null)
                {
                    return;
                }

                List<PageSummaryItem> items = new List<PageSummaryItem>();

                items.AddRange(
                    homeItem.Children.ToList().ConvertAll(x => new PageSummaryItem(x)).Where(
                        x => x.InnerItem.TemplateID.ToString() == ContentItem.TemplateId && !String.IsNullOrEmpty(x.NavigationTitle.Raw)));

                NavigationListView.DataSource = items;
                NavigationListView.DataBind();

                ClubMicrositeLandingItem landing = new ClubMicrositeLandingItem(landingItem);

                ClubItem club = new ClubItem(landing.Club.Item);

                OpeningHoursLiteral.Text = String.Format(Translate.Text("OPENING HOURS: {0}", club.Openinghours.Raw));
                TwitterUrl = landing.Twitterurl.Rendered;

                TwitterImage = "icon-twitter.png";
                if (Sitecore.Context.Item.TemplateID.ToString() == MicrositeHomeItem.TemplateId || Sitecore.Context.Item.TemplateID.ToString() == LocationItem.TemplateId)
                {
                    TwitterImage = "icon-white-twitter.png";
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            currentClub = SitecoreHelper.GetCurrentClub(currentItem);

            if (currentClub != null)
            {
                ClubHomeUrl = LinkManager.GetItemUrl(currentClub.InnerItem);
                ClubName = currentClub.Clubname.Raw;

                //Set Book Online Link
                if (currentClub.GetCrmSystem() == ClubCrmSystemTypes.ClubCentric || currentClub.GetCrmSystem() == ClubCrmSystemTypes.Vision)
                {
                    //Show link
                    pnlBookOnline.Visible = true;
                    BookOnlineUrl = SitecoreHelper.GetMembershipLoginUrl(currentClub);
                }
            }

            if (currentItem.InnerItem.HasChildren)
            {
                List<TimetableDownloadModuleItem> moduleList = currentItem.InnerItem.Children.ToList().ConvertAll(X => new TimetableDownloadModuleItem(X));

                DownloadModuleListing.DataSource = moduleList;
                DownloadModuleListing.DataBind();
            }

            //Set club last visited
            User objUser = new User();
            if (Session["sess_User"] != null)
            {
                objUser = (User)Session["sess_User"];
            }
            objUser.ClubLastVisitedID = currentClub.ClubId.Rendered;
            Session["sess_User"] = objUser;

            //Set club last visited cookie
            CookieHelper.AddClubsLastVisitedCookie(CookieKeyNames.ClubLastVisited, currentClub.ClubId.Rendered);

            //Add club name to page title
            string clubNameTitle = String.Format(" - {0}", currentClub.Clubname.Raw);
            clubNameTitle = HtmlRemoval.StripTagsCharArray(clubNameTitle);

            Page.Title = Page.Title + clubNameTitle;
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                if (Page.IsValid == true)
                {
                    //check if we have a valid club selected
                    Boolean blnClubSuccessfullySelected = clubFindSelect.SelectedIndex != 0;

                    if (blnClubSuccessfullySelected == true)
                    {
                        currentClub = (ClubItem)Sitecore.Context.Database.GetItem(clubFindSelect.SelectedValue);

                        if (currentClub != null)
                        {
                            //get managers info
                            List<ManagerItem> staffMembers = null;
                            if (currentClub.InnerItem.Axes.SelectItems(String.Format("descendant-or-self::*[@@tid = '{0}']", ManagerItem.TemplateId)) != null)
                            {
                                staffMembers = currentClub.InnerItem.Axes.SelectItems(String.Format("descendant-or-self::*[@@tid = '{0}']", ManagerItem.TemplateId)).ToList().ConvertAll(x => new ManagerItem(x));

                                manager = staffMembers.First();
                            }

                            //Data is sent to client via service
                            SendEnquiryDataService();

                            //Save feedback to report DB
                            SaveDataToReportDB();

                            //Send confirmation email
                            SendConfirmationEmail();

                            Response.Redirect(enquiryItem.PageSummary.Url + "?action=confirm");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(String.Format("Error processing club enquiry form {0}", ex.Message), this);
            }
        }
        /// <summary>
        /// To set the club associated
        /// </summary>
        private void SetClubItem()
        {
            string clubId = WebUtil.GetQueryString("_clubid");

            //Get User from Session
            //Check Session
            User objUser = new User();
            if (Session["sess_User_landing"] != null)
            {
                objUser = (User)Session["sess_User_landing"];

                clubId = objUser.BrowsingHistory.LandingClubID;

            }

            //Get Club Data

            if (!String.IsNullOrEmpty(clubId))
                clubItem = SitecoreHelper.GetClubOnClubId(clubId);
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                if (Page.IsValid == true)
                {
                    //Get User from Session
                    //Check Session
                    User objUser = new User();
                    if (Session["sess_User_landing"] != null)
                    {
                        objUser = (User)Session["sess_User_landing"];

                        clubId = objUser.BrowsingHistory.LandingClubID;
                        profile = objUser.BrowsingHistory.LandingProfile;
                        region = objUser.BrowsingHistory.LandingRegion;
                    }

                    //Get Club Data

                    if (!String.IsNullOrEmpty(clubId))
                    {
                        clubItem = SitecoreHelper.GetClubOnClubId(clubId);

                        if (clubItem != null)
                        {

                            //Store Feedback Entitiy Details
                            Feedback objFeedback = new Feedback();

                            //Store Customer Entitiy Details
                            Customer objCustomer = new Customer();

                            string FirstName = "";
                            string Surname = "";

                            if (txtName.Value.IndexOf(" ") != -1)
                            {
                                FirstName = txtName.Value.Substring(0, txtName.Value.IndexOf(" ")).Trim();
                                Surname = txtName.Value.Substring(txtName.Value.IndexOf(" ") + 1).Trim();
                            }
                            else
                            {
                                FirstName = txtName.Value.Trim();
                            }

                            objCustomer.EmailAddress = txtEmail.Value;
                            objCustomer.Firstname = FirstName;
                            objCustomer.Surname = Surname;
                            objCustomer.HomeClubID = clubItem.ClubId.Rendered;
                            objCustomer.TelephoneNumber = txtPhone.Value;
                            objCustomer.SubscribeToNewsletter = chkSubscribe.Checked;

                            objFeedback.Customer = objCustomer;
                            objFeedback.FeedbackSubject = "Landing Enquiry"; //Landing Enquiry
                            objFeedback.FeedbackSubjectDetail = "Virgin Active Website Landing Page"; //Virgin Active Website Landing Page
                            objFeedback.FeedbackTypeID = Convert.ToInt32(currentLanding.LandingBase.LandingId.Rendered);
                            objFeedback.PrimaryClubID = clubItem.ClubId.Rendered;
                            objFeedback.SubmissionDate = DateTime.Now;

                            //Add Comment
                            Comment objComment = new Comment();

                            //objComment.CommentDetail = source.Items[source.SelectedIndex].Value;
                            objComment.CommentDetail = currentLanding.LandingBase.LandingIdName.Rendered;// "Q1 Landing Page -2013"; //Other
                            objComment.CommentImageTypeID = Constants.CommentImageType.QuestionnaireAnswer;
                            objComment.SortOrder = 1;
                            objComment.Subject = Translate.Text("How did you hear about us?");

                            List<Comment> objComments = new List<Comment>();
                            objComments.Add(objComment);

                            objFeedback.Comments = objComments;

                            string connection = Sitecore.Configuration.Settings.GetSetting("ConnectionString_VirginActiveReports");
                            DataAccessLayer dal = new DataAccessLayer(connection);
                            int successFlag = dal.SaveFeedback(Context.User.Identity.Name, currentItem.DisplayName, objFeedback);

                            if (successFlag > 0)
                            {
                                //Data is sent to client via email
                                SendAdminEmail();

                                //Data is sent to client via service
                                SendEnquiryDataService();

                                //Data is sent to customer via email
                                SendConfirmationEmail();

                                //Save objFeedback back to session
                                Session["sess_Customer"] = objCustomer;

                                //Redirect to 'Whats Next' Page
                                Sitecore.Links.UrlOptions urlOptions = new Sitecore.Links.UrlOptions();
                                urlOptions.AlwaysIncludeServerUrl = true;
                                urlOptions.AddAspxExtension = false;
                                urlOptions.LanguageEmbedding = LanguageEmbedding.Never;

                                Item whatNextItem = currentItem.InnerItem.Parent.Axes.SelectSingleItem(String.Format("descendant-or-self::*[@@tid = '{0}']", Settings.LandingPagesWhatsNextTemplate));

                                string whatNextUrl = Sitecore.Links.LinkManager.GetItemUrl(whatNextItem, urlOptions)+"?_clubid=" + clubItem.ClubId.Rendered;

                                Response.Redirect(whatNextUrl);
                            }
                            else
                            {
                                //imageStatic.Attributes.Add("style", "display:none;");
                                //formToComplete.Attributes.Add("style", "display:block;");
                                //formCompleted.Attributes.Add("style", "display:none;");
                                //pnlForm.Update();

                                Log.Error(String.Format("Error storing campaign details"), this);
                            }
                        }
                        else
                        {
                            //imageStatic.Attributes.Add("style", "display:none;");
                            //formToComplete.Attributes.Add("style", "display:block;");
                            //formCompleted.Attributes.Add("style", "display:none;");
                            //pnlForm.Update();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(String.Format("Error processing club enquiry form {0}", ex.Message), this);
                mm.virginactive.common.EmailMessagingService.ErrorEmailNotification.SendMail(ex);
            }
        }
        private void SetSitecoreData()
        {
            //Get User from Session
            //Check Session
            User objUser = new User();
            if (Session["sess_User_landing"] != null)
            {
                objUser = (User)Session["sess_User_landing"];

                clubId = objUser.BrowsingHistory.LandingClubID;
                profile = objUser.BrowsingHistory.LandingProfile;
                region = objUser.BrowsingHistory.LandingRegion;
            }

            //Set currentLanding item
            if (currentItem != null)
            {
                currentLanding = currentItem.InnerItem.Parent;
            }

            if (currentLanding != null)
                btnSubmit.Attributes.Add("data-gaqlabel", currentLanding.LandingBase.LandingId.Rendered);

            //Get Club Data

            if (!String.IsNullOrEmpty(clubId))
                clubItem = SitecoreHelper.GetClubOnClubId(clubId);

            if (clubItem != null)
            {
                //Image Carousel
                List<MediaItem> imageList;
                if (!String.IsNullOrEmpty(clubItem.Imagegallery.Raw))
                {
                    imageList = clubItem.Imagegallery.ListItems.ConvertAll(X => new MediaItem(X));

                    ClubImages.DataSource = imageList;
                    ClubImages.DataBind();
                }

                System.Text.StringBuilder markupBuilder;
                markupBuilder = new System.Text.StringBuilder();

                markupBuilder.Append(clubItem.Addressline1.Rendered);
                markupBuilder.Append(!String.IsNullOrEmpty(clubItem.Addressline2.Rendered) ? ", " + clubItem.Addressline2.Rendered : "");
                markupBuilder.Append(!String.IsNullOrEmpty(clubItem.Addressline3.Rendered) ? ", " + clubItem.Addressline3.Rendered : "");
                markupBuilder.Append(!String.IsNullOrEmpty(clubItem.Addressline4.Rendered) ? ", " + clubItem.Addressline4.Rendered : "");
                markupBuilder.Append(", " + clubItem.Postcode.Rendered);
                markupBuilder.Append(" | " + clubItem.Salestelephonenumber.Rendered);

                litClubAddress.Text = markupBuilder.ToString();

                Item timetableItem = clubItem.InnerItem.Axes.SelectSingleItem(String.Format("child::*[@@name='{0}']", Settings.TimetableSectionName.ToLower()));

                    //clubItem.InnerItem.Axes.SelectSingleItem(String.Format("descendant::*[@@name='{0}']", Settings.TimetableSectionName));
                if (timetableItem != null)
                {
                    Sitecore.Links.UrlOptions urlOptions = new Sitecore.Links.UrlOptions();
                    urlOptions.AlwaysIncludeServerUrl = true;
                    urlOptions.AddAspxExtension = false;
                    urlOptions.LanguageEmbedding = LanguageEmbedding.Never;

                    string timetableUrl = Sitecore.Links.LinkManager.GetItemUrl(timetableItem, urlOptions);

                    TimeTableUrl = timetableUrl;
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Boolean specificSearchMatch = false;
            SkinnyItem SearchPrompt = null;

            //Check for special search term matches
            Item componentBase = Sitecore.Context.Database.GetItem(ItemPaths.Components);

            if (componentBase != null)
            {
                Item[] terms = componentBase.Axes.SelectItems(String.Format("descendant::*[@@tid='{0}']", SearchTermItem.TemplateId));
                if (terms != null)
                {
                    foreach (Item term in terms)
                    {
                        SearchTermItem itm = new SearchTermItem(term);

                        if (itm.Predictiveterm.Raw.Trim() != "")
                        {
                            Regex match = new Regex(itm.Predictiveterm.Raw);
                            if (match.IsMatch(Query))
                            {
                                specificSearchMatch = true;
                                SearchPrompt = new SkinnyItem(itm.InnerItem.Uri);
                                break;
                            }
                        }

                    }
                }
            }

            if (!String.IsNullOrEmpty(Query))
            {
                StringWriter result = new StringWriter();

                using (JsonTextWriter w = new JsonTextWriter(result))
                {
                    w.WriteStartArray();

                    //Advanced Database Search
                    var resultItems = new List<SkinnyItem>();
                    //var stopwatch = new Stopwatch();
                    try
                    {
                        //stopwatch.Start();
                        resultItems.AddRange(GetItems());
                        //stopwatch.Stop();

                        //Categorise the results
                        var clubResultList = new List<SkinnyItem>();
                        var classResultList = new List<SkinnyItem>();
                        var facilityResultList = new List<SkinnyItem>();

                        foreach (var resultItem in resultItems)
                        {
                            //check if hidden from menu
                            if (resultItem.Fields["_ishiddenfrommenu"] != null)
                            {
                                if (resultItem.Fields["_ishiddenfrommenu"].ToString() == "false" || resultItem.Fields["_showinsearchbar"].ToString() == "true")
                                {
                                    switch (resultItem.TemplateName)
                                    {
                                        case Templates.ClassicClub:
                                            clubResultList.Add(resultItem);
                                            break;
                                        case Templates.LifeCentre:
                                            clubResultList.Add(resultItem);
                                            break;
                                        case Templates.ClassModule:
                                            classResultList.Add(resultItem);
                                            break;
                                        case Templates.FacilityModule:
                                            facilityResultList.Add(resultItem);
                                            break;
                                    }
                                }
                            }
                            else
                            {
                                switch (resultItem.TemplateName)
                                {
                                    case Templates.ClassicClub:
                                        clubResultList.Add(resultItem);
                                        break;
                                    case Templates.LifeCentre:
                                        clubResultList.Add(resultItem);
                                        break;
                                    case Templates.ClassModule:
                                        classResultList.Add(resultItem);
                                        break;
                                    case Templates.FacilityModule:
                                        facilityResultList.Add(resultItem);
                                        break;
                                }
                            }
                        }

                        var filteredSortedList = new List<SkinnyItem>();

                        int j = 0; //total search result count
                        int i = 0; //category search result count

                        int categorySearchResultLimit = Settings.MaxCategorySearchResults;

                        int totalSearchResultLimit = Settings.MaxTotalSearchResults;

                        //filter and reorder the result set
                        foreach (var item in clubResultList)
                        {
                            //only read top x results
                            if (i < categorySearchResultLimit && j < totalSearchResultLimit)
                            {
                                filteredSortedList.Add(item);
                            }
                            else { break; }
                            i++;
                            j++;
                        }
                        //If specific search match found then add "more club results exist for this search" message and link (e.g. searching for London, Manchester)
                        if (i == categorySearchResultLimit && SearchPrompt != null)
                        {
                            filteredSortedList.Add(SearchPrompt);
                        }

                        i = 0;
                        foreach (var item in classResultList)
                        {
                            //only read top x results
                            if (i < categorySearchResultLimit && j < totalSearchResultLimit)
                            {
                                filteredSortedList.Add(item);
                            }
                            else { break; }
                            i++;
                            j++;
                        }
                        i = 0;

                        foreach (var item in facilityResultList)
                        {
                            //Only show in results if facility exists as a GUID in MultiList in main site area -N.B. potentially take out if taking too long

                            //Get the facilities from landing page item's facility list
                            FacilitiesLandingItem facilitiesLandingItem = Sitecore.Context.Database.GetItem(ItemPaths.FacilitiesLanding);
                            MultilistField facilityLandingList = facilitiesLandingItem.InnerItem.Fields["Facility List"];

                            foreach (Item facilityModuleItem in facilityLandingList.GetItems())
                            {
                                if (facilityModuleItem.Name == item.Name)
                                {
                                    //Facility is in main site -Add to results list

                                    //only read top x results
                                    if (i < categorySearchResultLimit && j < totalSearchResultLimit)
                                    {
                                        filteredSortedList.Add(item);
                                    }
                                    else { break; }
                                    i++;
                                    j++;
                                }
                            }
                        }

                        //write out results
                        foreach (var filteredSortedItem in filteredSortedList)
                        {
                            Item resultItem = filteredSortedItem.GetItem();
                            //Get the markup for presenting the result
                            string resultHTML = SearchResult.RenderToString(resultItem, Query);
                            Sitecore.Links.UrlOptions urlOptions = new Sitecore.Links.UrlOptions();
                            urlOptions.AddAspxExtension = false;
                            urlOptions.AlwaysIncludeServerUrl = true;
                            urlOptions.LanguageEmbedding = LanguageEmbedding.Never;
                            string resultUrl = "";

                            switch (resultItem.TemplateName)
                            {
                                case Templates.SearchTerm:
                                    string clubFinderUrl = new PageSummaryItem(Sitecore.Context.Database.GetItem(ItemPaths.ClubResults)).Url;
                                    System.Text.StringBuilder url = new System.Text.StringBuilder();
                                    url.Append(clubFinderUrl);
                                    if (resultItem.Fields["Lat"] != null && resultItem.Fields["Long"] != null)
                                    {
                                        url.Append("?lat=" + resultItem.Fields["Lat"].Value);
                                        url.Append("&lng=" + resultItem.Fields["Long"].Value);
                                        url.Append("&searchloc=" + resultItem.DisplayName);
                                        url.Append("&ste=" + Query);
                                        url.Append("&sty=2");
                                    }
                                    resultUrl = url.ToString();
                                    break;
                                case Templates.ClassicClub:
                                    ClubItem ClubItm = new ClubItem(resultItem);

                                    //check if club is just a placeholder for a campaign
                                    if (ClubItm.IsPlaceholder.Checked == true)
                                    {
                                        Item campaign;

                                        if (ClubItm.PlaceholderCampaign.Item.TemplateID.ToString() == ClubMicrositeLandingItem.TemplateId)
                                        {
                                            campaign =
                                                ClubItm.PlaceholderCampaign.Item.Axes.SelectSingleItem(
                                                    String.Format("*[@@tid='{0}']", MicrositeHomeItem.TemplateId));
                                        }
                                        else
                                        {

                                            //redirect to campaign
                                            campaign = ClubItm.PlaceholderCampaign.Item;

                                        }

                                        if (campaign != null)
                                        {
                                            resultUrl = LinkManager.GetItemUrl(campaign, urlOptions);
                                        }
                                        else
                                        {
                                            resultUrl = Sitecore.Links.LinkManager.GetItemUrl(resultItem, urlOptions);
                                        }
                                    }
                                    else
                                    {
                                        resultUrl = Sitecore.Links.LinkManager.GetItemUrl(resultItem, urlOptions);
                                    }
                                    break;
                                case Templates.LifeCentre:
                                    CheckboxField IsPlaceholderLife = resultItem.Fields["Is Placeholder"];
                                    if (IsPlaceholderLife.Checked == true)
                                    {
                                        //redirect to campaign
                                        Item campaign = Sitecore.Context.Database.GetItem(resultItem.Fields["Placeholder Campaign"].Value);

                                        if (campaign != null)
                                        {
                                            UrlOptions opt = new UrlOptions();
                                            opt.AddAspxExtension = false;
                                            opt.LanguageEmbedding = LanguageEmbedding.Never;
                                            opt.AlwaysIncludeServerUrl = true;

                                            resultUrl = LinkManager.GetItemUrl(campaign, opt);
                                        }
                                        else
                                        {
                                            resultUrl = Sitecore.Links.LinkManager.GetItemUrl(resultItem, urlOptions);
                                        }
                                    }
                                    else
                                    {
                                        resultUrl = Sitecore.Links.LinkManager.GetItemUrl(resultItem, urlOptions);
                                    }
                                    break;
                                default:
                                    resultUrl = Sitecore.Links.LinkManager.GetItemUrl(resultItem, urlOptions);
                                    break;
                            }

                            //Write out html and result into JSON object
                            WriteResultAsJson(w, resultHTML, resultUrl);

                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Error(String.Format("Unable to load search results: {0}", ex.Message), null);
                        mm.virginactive.common.EmailMessagingService.ErrorEmailNotification.SendMail(ex);
                    }
                    finally
                    {
                        //stopwatch.Stop();
                    }

                    w.WriteEndArray();

                    Response.Write(result.ToString());
                }
            }
            else
            {
                Log.Error(String.Format("Unable to load search results: No query passed in"), null);
            }
        }
Exemple #17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //set current item
            currentItem = Sitecore.Context.Database.GetItem(ItemPaths.Header);

            //Header links
            Item[] links = currentItem.InnerItem.Axes.SelectItems(String.Format("child::*[@@tid='{0}']", LinkItem.TemplateId));
            if (links != null)
            {
                List<LinkItem> headerLinks = links.ToList().ConvertAll(X => new LinkItem(X));
                LinkList.DataSource = headerLinks;
                LinkList.DataBind();
            }

            //Set featured promo link and home page link
            Sitecore.Links.UrlOptions urlOptions = new Sitecore.Links.UrlOptions();
            urlOptions.AlwaysIncludeServerUrl = true;
            urlOptions.AddAspxExtension = true;
            urlOptions.LanguageEmbedding = LanguageEmbedding.Never;

            //set Featured Promo Event Teaser
            if (currentItem.InnerItem.HasChildren)
            {
                List<FeaturedPromotionEventWidgetItem> allFeatures = currentItem.InnerItem.Children.ToList().ConvertAll(X => new FeaturedPromotionEventWidgetItem(X));
                fpew = new FeaturedPromotionEventWidgetItem(allFeatures.First());
            }

            //Set home page link (set as club home if home club set)
            string startPath = Sitecore.Context.Site.StartPath.ToString();
            var homeItem = Sitecore.Context.Database.GetItem(startPath);
            hdnLastClubVisitedId.Value = "";

            //set hidden field for javascript referencing
            homePageUrl.Value = Sitecore.Links.LinkManager.GetItemUrl(homeItem, urlOptions);
            homePageUrl.Value = homePageUrl.Value.IndexOf("Home.aspx") != -1 ? homePageUrl.Value : homePageUrl.Value + "Home.aspx";

            //Set home page link
            homeOrClubPageUrl = Sitecore.Links.LinkManager.GetItemUrl(homeItem, urlOptions);

            //Set Header Text -need logic to display <h1> or <h2>
            //Format Contact Address
            System.Text.StringBuilder markupBuilder = new System.Text.StringBuilder();

            if (Sitecore.Context.Item.ID == homeItem.ID)
            {
                //Page is home page
                markupBuilder.Append(@"<h1 class=""headertext""><a href=""");
                markupBuilder.Append(HomeOrClubPageUrl + @""">");
                markupBuilder.Append(Translate.Text("Virgin Active") + " <span>");
                markupBuilder.Append(Translate.Text("Health Clubs") + "</span></a></h1>");
            }
            else
            {
                markupBuilder.Append(@"<h2 class=""headertext""><a href=""");
                markupBuilder.Append(HomeOrClubPageUrl + @""">");
                markupBuilder.Append(Translate.Text("Virgin Active") + " <span>");
                markupBuilder.Append(Translate.Text("Health Clubs") + "</span></a></h2>");
            }

            ltrHeaderText.Text = markupBuilder.ToString();

            //CREATE NEW USER SESSION
            //Check if we are loading home page for the first time
            User objUser = new User();

            //Check Session
            if (Session["sess_User"] == null)
            {
                newSession = true;
            }
            else
            {
                objUser = (User)Session["sess_User"];
            }

            //READ/SET COOKIE OPTIONS
            if (newSession)
            {
                //New Session

                //Check gallery preference
                if (!string.IsNullOrEmpty(CookieHelper.GetCookieValue(CookieKeyNames.ShowGallery)))
                {
                    //Store to session
                    objUser.ShowGallery = CookieHelper.GetCookieValue(CookieKeyNames.ShowGallery) == "Y" ? true : false;
                }

                //Check if cookie preferences session cookie exists
                if (!string.IsNullOrEmpty(CookieHelper.GetOptInCookieValue(CookieKeyNames.MarketingCookies)))
                {
                    Preferences preferences = new Preferences();

                    preferences.MarketingCookies = CookieHelper.GetOptInCookieValue(CookieKeyNames.MarketingCookies) == "Y" ? true : false;
                    preferences.MetricsCookies = CookieHelper.GetOptInCookieValue(CookieKeyNames.MetricsCookies) == "Y" ? true : false;
                    preferences.PersonalisedCookies = CookieHelper.GetOptInCookieValue(CookieKeyNames.PersonalisedCookies) == "Y" ? true : false;
                    preferences.SocialCookies = CookieHelper.GetOptInCookieValue(CookieKeyNames.SocialCookies) == "Y" ? true : false;

                    //Store to session
                    objUser.Preferences = preferences;
                }
                else
                {
                    //Interorgate the request 'Do Not Track' settings.
                    HttpContext objContext = HttpContext.Current;
                    bool headerDoNotTrack = false;

                    if (!string.IsNullOrEmpty(objContext.Request.Headers["DNT"]))
                    {
                        headerDoNotTrack = objContext.Request.Headers["DNT"] == "1" ? true : false;
                    }

                    if (headerDoNotTrack)
                    {
                        //Set Preferences in User Session -default to N
                        Preferences preferences = new Preferences();

                        preferences.MarketingCookies = false;
                        preferences.MetricsCookies = false;
                        preferences.PersonalisedCookies = false;
                        preferences.SocialCookies = false;

                        objUser.Preferences = preferences;

                        //Set Cookie Preferences Cookie
                        CookieHelper.AddUpdateOptInCookie(CookieKeyNames.MarketingCookies, "N");
                        CookieHelper.AddUpdateOptInCookie(CookieKeyNames.MetricsCookies, "N");
                        CookieHelper.AddUpdateOptInCookie(CookieKeyNames.PersonalisedCookies, "N");
                        CookieHelper.AddUpdateOptInCookie(CookieKeyNames.SocialCookies, "N");

                        //Delete Existing Personalisation Cookie
                        CookieHelper.DeleteCookie();
                    }
                }
            }

            //DEFAULT PREFERENCES
            if (objUser.Preferences == null)
            {
                //Set preferences in User Session -default to Y
                Preferences preferences = new Preferences();

                preferences.MarketingCookies = true;
                preferences.MetricsCookies = true;
                preferences.PersonalisedCookies = true;
                preferences.SocialCookies = true;

                //Store to session
                objUser.Preferences = preferences;

                //Set Cookie Preferences Cookie -default to permission allowed
                CookieHelper.AddUpdateOptInCookie(CookieKeyNames.MarketingCookies, "Y");
                CookieHelper.AddUpdateOptInCookie(CookieKeyNames.MetricsCookies, "Y");
                CookieHelper.AddUpdateOptInCookie(CookieKeyNames.PersonalisedCookies, "Y");
                CookieHelper.AddUpdateOptInCookie(CookieKeyNames.SocialCookies, "Y");
            }

            //SHOW/HIDE PERSONALISED CONTENT
            if (newSession && (Sitecore.Context.Item.ID == homeItem.ID))
            {
                //Loading home page for the first time -Check if last page visited cookie exists
                //if(!string.IsNullOrEmpty(CookieHelper.GetCookieValue(CookieKeyNames.ClubLastVisited)))
                if (!string.IsNullOrEmpty(CookieHelper.GetClubLastVisitedCookieValue(CookieKeyNames.ClubLastVisited)))
                {
                    //Display message prompting then to go to club
                    phLastClubVisitedPrompt.Visible = true;
                    //clubLastVisited = SitecoreHelper.GetClubOnClubId(CookieHelper.GetCookieValue(CookieKeyNames.ClubLastVisited));
                    clubLastVisited = SitecoreHelper.GetClubOnClubId(CookieHelper.GetClubLastVisitedCookieValue(CookieKeyNames.ClubLastVisited));
                    if (clubLastVisited != null)
                    {
                        ClubLastVisitedUrl = Sitecore.Links.LinkManager.GetItemUrl(clubLastVisited, urlOptions);
                        ClubName = clubLastVisited.Clubname.Rendered;
                        hdnLastClubVisitedId.Value = clubLastVisited.ClubId.Rendered;

                        //Store to session
                        objUser.ClubLastVisitedID = clubLastVisited.ClubId.Rendered;
                    }
                }
            }
            else
            {
                //User session already exists but only visiting home page for the first time
                if ((objUser.HomePageVisited == false) && (Sitecore.Context.Item.ID == homeItem.ID))
                {
                    //if (!string.IsNullOrEmpty(CookieHelper.GetCookieValue(CookieKeyNames.ClubLastVisited)))
                    if (!string.IsNullOrEmpty(CookieHelper.GetClubLastVisitedCookieValue(CookieKeyNames.ClubLastVisited)))
                    {
                        //Display message prompting then to go to club
                        phLastClubVisitedPrompt.Visible = true;
                        //clubLastVisited = SitecoreHelper.GetClubOnClubId(CookieHelper.GetCookieValue(CookieKeyNames.ClubLastVisited));
                        clubLastVisited = SitecoreHelper.GetClubOnClubId(CookieHelper.GetClubLastVisitedCookieValue(CookieKeyNames.ClubLastVisited));
                        if (clubLastVisited != null)
                        {
                            ClubLastVisitedUrl = Sitecore.Links.LinkManager.GetItemUrl(clubLastVisited, urlOptions);
                            ClubName = clubLastVisited.Clubname.Rendered;
                            hdnLastClubVisitedId.Value = clubLastVisited.ClubId.Rendered;

                            //Store to session
                            objUser.ClubLastVisitedID = clubLastVisited.ClubId.Rendered;
                        }
                    }
                }
            }

            //Check if a club has been set as home page
            if (!String.IsNullOrEmpty(CookieHelper.GetCookieValue(CookieKeyNames.HomeClub)))
            {
                ClubItem club = SitecoreHelper.GetClubOnClubId(CookieHelper.GetCookieValue(CookieKeyNames.HomeClub));
                if (club != null)
                {
                    homeOrClubPageUrl = Sitecore.Links.LinkManager.GetItemUrl(club, urlOptions);

                    //Store to session
                    objUser.HomeClubID = club.ClubId.Rendered;
                }
            }

            //Save session
            Session["sess_User"] = objUser;

            Sitecore.Data.Items.Item headerItem = Sitecore.Context.Database.GetItem("/sitecore/content/page-elements/header");

            //Get featured promotion event item details for banner
            Sitecore.Data.Items.Item featuredPromotionEventItem = Sitecore.Context.Database.GetItem("/sitecore/content/Widgets/featured-promotion-event");
            if (featuredPromotionEventItem != null)
            {
                //fldPromotionEventDate.DataSource = featuredPromotionEventItem.ID.ToString();

                //fldPromotionEventSubheading.DataSource = featuredPromotionEventItem.ID.ToString();
            }
        }
Exemple #18
0
 private void HandleClubItemData(ClubItem clubGameObject)
 {
     clubGameObject.clubButton.onClick.RemoveAllListeners();
     clubGameObject.clubButton.onClick.AddListener(() => { OnClubClicked(clubGameObject.Data.id); });
 }
        private void BindDropDownLists()
        {
            try
            {
                //If this form is being called froma  club area, we will get a ShortGuid of the
                //originating club within the QS
                string clubQry = String.Empty;
                if (WebUtil.GetQueryString("c") != null)
                {
                    clubQry = WebUtil.GetQueryString("c");
                }

                Item clubRoot = Sitecore.Context.Database.GetItem(ItemPaths.Clubs);
                ChildList clubLst = clubRoot.Children;
                Item[] clubs = clubLst.ToArray();

                //Populate the club selector
                List<ClubItem> clubList = clubs.ToList().ConvertAll(X => new ClubItem(X));
                clubList.RemoveAll(x => x.IsHiddenFromMenu());
                clubList.RemoveAll(x => x.IsPlaceholder.Checked && !x.ShowInClubSelect.Checked);
                clubFindSelect.Items.Add(new ListItem(Translate.Text("Select a club"), ""));

                foreach (Item club in clubList)
                {
                    ClubItem clubItem = new ClubItem(club);
                    if (clubItem != null)
                    {
                        if (!String.IsNullOrEmpty(clubItem.Clubname.Text))
                        {
                            string clubLabel = HtmlRemoval.StripTagsCharArray(clubItem.Clubname.Text).Trim();

                            clubFindSelect.Items.Add(new ListItem(clubLabel, clubItem.ID.ToString()));

                            bool isSelected = clubQry.Equals(clubItem.ID.ToShortID().ToString());
                            if (isSelected)
                            {
                                clubFindSelect.SelectedValue = clubItem.ID.ToString();

                                //Set club details
                                ClubSalesNumber = clubItem.Salestelephonenumber.Raw;
                                clubDetails.Visible = true;
                                ClubResponseTapCode = clubItem.ResponseTapCode.Rendered;

                                ClubName =  HtmlRemoval.StripTagsCharArray(clubItem.Clubname.Rendered);
                                //txtClubName.Value = ClubName;
                                //txtClubName.Visible = true;
                                clubFindSelect.Visible = false;
                            }
                        }
                    }
                }

            }
            catch (Exception ex)
            {
                Log.Error(String.Format("Error binding drop down lists {1}: {0}", ex.Message, currentClub.Clubname.Raw), this);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //Check if listing is already initialised (i.e. loaded as the default listing page for the landing page)
            if (listing != null)
            {
                //Add datepicker jquery plugin script
                this.Page.FindControl("ScriptPh").Controls.Add(new LiteralControl(@"<script src=""/virginactive/scripts/jquery-ui-1.8.15.custom.min.js""></script>"));

                //Register script
                this.Page.FindControl("ScriptPh").Controls.Add(new LiteralControl(@"<script>
                $(function(){
                    $.va_init.functions.addDatepicker();
                    $.va_init.functions.addTreatmentToDropDown();
                });
                </script>"));

                //Get club
                club = SitecoreHelper.GetCurrentClub(listing.InnerItem);

                //get the details of the first manager listed for the club (i.e. the manager)
                List<ManagerItem> staffMembers = null;
                Item[] mgrItems =  club.InnerItem.Axes.SelectItems(String.Format("descendant-or-self::*[@@tid = '{0}']", ManagerItem.TemplateId));
                if (mgrItems != null)
                {
                    staffMembers = mgrItems.ToList().ConvertAll(x => new ManagerItem(x));
                    clubManager = staffMembers.First();
                }

                //Get the facility modules that are to be shown on listing page
                treatmentModules = listing.Sharedtreatments.ListItems.ToList().ConvertAll(X => new TreatmentModuleItem(X));

                foreach (TreatmentModuleItem module in treatmentModules)
                {
                    //find which brand the treatment belows to
                    sharedLanding = new HealthAndBeautyLandingItem(module.InnerItem.Axes.SelectSingleItem(String.Format(@"ancestor-or-self::*[@@tid=""{0}""]", HealthAndBeautyLandingItem.TemplateId)));
                    sharedListing = new HealthAndBeautyListingItem(module.InnerItem.Axes.SelectSingleItem(String.Format(@"ancestor-or-self::*[@@tid=""{0}""]", HealthAndBeautyListingItem.TemplateId)));
                    break;
                }

                if (sharedLanding != null)
                {

                    string section = Sitecore.Web.WebUtil.GetQueryString("section");

                    if (!String.IsNullOrEmpty(section))
                    {
                        //get the correct section listing item from the querystring
                        sharedListing = sharedLanding.InnerItem.Axes.GetDescendant(section);
                    }

                    if (sharedListing != null)
                    {
                        if (listing.Pricelistavailable.Checked == true && listing.Pricelist != null)
                        {
                            downloadPriceListUrl = listing.Pricelist.MediaUrl;
                            downloadPriceList = @"<li><a href=""" + downloadPriceListUrl + @""">" + Translate.Text("Download a price list") + "</a></li>";
                        }
                        else
                        {
                            PriceList.Visible = false;
                        }

                        //Get list of shared treaments
                        if (sharedListing.InnerItem.HasChildren)
                        {
                            List<TreatmentModuleItem> sharedTreatmentList = sharedListing.InnerItem.Children.ToList().ConvertAll(X => new TreatmentModuleItem(X));
                            foreach (TreatmentModuleItem sharedTreatmentModule in sharedTreatmentList)
                            {
                                //Check if this treatment has been included for this club
                                foreach(TreatmentModuleItem module in treatmentModules)
                                {
                                    if (module.ID.ToString() == sharedTreatmentModule.ID.ToString())
                                    {
                                        //Show this treatment
                                        treatmentListToShow.Add(module);
                                    }
                                }
                            }

                            if (treatmentListToShow.Count > 0)
                            {
                                treatmentListToShow.First().IsFirst = true;

                                TreatmentList.DataSource = treatmentListToShow;
                                TreatmentList.DataBind();
                            }

                        }
                    }
                }

                string val = Translate.Text("Please enter {0}");
                rfvName.ErrorMessage = String.Format("<div class='error-msg'><p>{0}</p></div>", String.Format(val, Translate.Text("a name")));
                revName.ErrorMessage = String.Format("<div class='error-msg'><p>{0}</p></div>", String.Format(val, Translate.Text("a valid name")));
                rfvEmail.ErrorMessage = String.Format("<div class='error-msg'><p>{0}</p></div>", String.Format(val, Translate.Text("an email address")));
                revEmail.ErrorMessage = String.Format("<div class='error-msg'><p>{0}</p></div>", String.Format(val, Translate.Text("a valid email address")));
                rfvPhone.ErrorMessage = String.Format("<div class='error-msg'><p>{0}</p></div>", String.Format(val, Translate.Text("a phone number")));
                revPhone.ErrorMessage = String.Format("<div class='error-msg'><p>{0}</p></div>", String.Format(val, Translate.Text("a valid phone number")));
                //rfvComments.ErrorMessage = String.Format("<p>{0}</p>", String.Format(val, Translate.Text("your comments")));
                revEmail.ValidationExpression = Settings.EmailAddressRegularExpression;
                revPhone.ValidationExpression = Settings.PhoneNumberRegularExpression;
                revName.ValidationExpression = Settings.NameRegularExpression;

                if (!Page.IsPostBack)
                {
                    BindDropDownLists();
                }
            }

            this.Page.FindControl("ScriptPh").Controls.Add(new LiteralControl(@"<script>
                $(function(){
                    $.va_init.functions.setupForms();
                });
                </script>"));
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                bool blnIsValid = clubFindSelect.SelectedIndex != 0;

                if (blnIsValid == true)
                {
                    currentClub = (ClubItem)Sitecore.Context.Database.GetItem(clubFindSelect.SelectedValue);

                    if (currentClub != null)
                    {

                    //Store Feedback Entitiy Details
                    Feedback objFeedback = new Feedback();

                    //Store Customer Entitiy Details
                    Customer objCustomer = new Customer();

                    string FirstName = "";
                    string Surname = "";

                    if (yourname.Value.IndexOf(" ") != -1)
                    {
                        FirstName = yourname.Value.Substring(0, yourname.Value.IndexOf(" ")).Trim();
                        Surname = yourname.Value.Substring(yourname.Value.IndexOf(" ") + 1).Trim();
                    }
                    else
                    {
                        FirstName = yourname.Value.Trim();
                    }

                    objCustomer.EmailAddress = email.Value;
                    objCustomer.Firstname = FirstName;
                    objCustomer.Surname = Surname;
                    //objCustomer.HomeClubID = txtClubCode.Value;
                    objCustomer.HomeClubID = currentClub.ClubId.Rendered;
                    objCustomer.SubscribeToNewsletter = false;
                    objCustomer.TelephoneNumber = contact.Value;

                    objFeedback.Customer = objCustomer;
                    objFeedback.FeedbackSubject = campaign.CampaignBase.Campaigntype.Raw;
                    objFeedback.FeedbackSubjectDetail = campaign.CampaignBase.Campaignname.Rendered;
                    objFeedback.FeedbackTypeID = Convert.ToInt32(campaign.CampaignBase.CampaignId.Rendered);
                    objFeedback.PrimaryClubID = currentClub.ClubId.Rendered;
                    objFeedback.SubmissionDate = DateTime.Now;

                    string connection = Sitecore.Configuration.Settings.GetSetting("ConnectionString_VirginActiveReports");
                    DataAccessLayer dal = new DataAccessLayer(connection);
                    int successFlag = dal.SaveFeedback(Context.User.Identity.Name, campaign.DisplayName, objFeedback);

                    if (successFlag > 0)
                    {
                        //Data is sent to client via email
                        SendAdminEmail();

                        if (campaign.CampaignBase.Isweblead.Checked == true)
                        {
                            //Data is sent to client via service
                            SendEnquiryDataService();
                        }

                        //get managers info
                        List<ManagerItem> staffMembers = null;
                        if (currentClub.InnerItem.Axes.SelectItems(String.Format("descendant-or-self::*[@@tid = '{0}']", ManagerItem.TemplateId)) != null)
                        {
                            staffMembers = currentClub.InnerItem.Axes.SelectItems(String.Format("descendant-or-self::*[@@tid = '{0}']", ManagerItem.TemplateId)).ToList().ConvertAll(x => new ManagerItem(x));

                            manager = staffMembers.First();
                        }

                        if (campaign.CampaignBase.Sendconfirmationemail.Checked == true)
                        {
                            //Data is sent to customer via email
                            SendConfirmationEmail();
                        }

                        imageStatic.Attributes.Add("style", "display:none;");
                        innerForm.Attributes.Add("style", "display:none;");
                        formCompleted.Attributes.Add("style", "display:block;");

                        string classNames = article.Attributes["class"];
                        article.Attributes.Add("class", classNames.Length > 0 ? classNames + " ImageOverlay" : "ImageOverlay");
                        ClearFormFields();
                    }
                    else
                    {
                        imageStatic.Attributes.Add("style", "display:none;");
                        innerForm.Attributes.Add("style", "display:block;");
                        formCompleted.Attributes.Add("style", "display:none;");

                        string classNames = article.Attributes["class"];
                        article.Attributes.Add("class", classNames.Length > 0 ? classNames + " ImageOverlay" : "ImageOverlay");

                        Log.Error(String.Format("Error storing campaign details"), this);
                    }
                }
                else
                {
                    imageStatic.Attributes.Add("style", "display:none;");
                    innerForm.Attributes.Add("style", "display:block;");
                    formCompleted.Attributes.Add("style", "display:none;");

                    string classNames = article.Attributes["class"];
                    article.Attributes.Add("class", classNames.Length > 0 ? classNames + " ImageOverlay" : "ImageOverlay");
                }
                }

            }
            catch (Exception ex)
            {
                Log.Error(String.Format("Error storing campaign details: {0}", ex.Message), this);
                mm.virginactive.common.EmailMessagingService.ErrorEmailNotification.SendMail(ex);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //This is a timetable item (or microsite timetable item -treated the same)
            timetableItem = new TimetableItem(Sitecore.Context.Item);

            List<PageSummaryItem> sectionTimetables = null;
            if (Sitecore.Context.Item.TemplateID.ToString() == TimetableItem.TemplateId.ToString())
            {
                //This is a timetable item
                currentClub = new ClubItem(Sitecore.Context.Item.Axes.SelectSingleItem(String.Format(@"ancestor-or-self::*[@@tid=""{0}"" or @@tid=""{1}""]", ClassicClubItem.TemplateId, LifeCentreItem.TemplateId)));
                ClubHomeUrl = currentClub != null ? LinkManager.GetItemUrl(currentClub.InnerItem) : "";

                sectionTimetables = timetableItem.InnerItem.Axes.SelectItems(String.Format("..//*[@@tid='{0}']", TimetableItem.TemplateId)).ToList().ConvertAll(x => new PageSummaryItem(x));
                sectionTimetables.RemoveAll(x => x.Hidefrommenu.Checked); //Remove all hidden items
            }
            else
            {
                //This is a microsoft timetable item
                MicrositeHomeItem micrositeHome = new MicrositeHomeItem(timetableItem.InnerItem.Axes.SelectSingleItem(String.Format(@"ancestor-or-self::*[@@tid=""{0}""]", MicrositeHomeItem.TemplateId)));
                ClubMicrositeLandingItem micrositeLanding = micrositeHome.InnerItem.Parent;
                currentClub = micrositeLanding.Club.Item;
                ClubHomeUrl = currentClub != null ? LinkManager.GetItemUrl(micrositeHome.InnerItem) : "";

                sectionTimetables = timetableItem.InnerItem.Axes.SelectItems(String.Format("..//*[@@tid='{0}']", MicrositeTimetableItem.TemplateId)).ToList().ConvertAll(x => new PageSummaryItem(x));
                sectionTimetables.RemoveAll(x => x.Hidefrommenu.Checked); //Remove all hidden items
            }

            //Set Navigation elements

            if (sectionTimetables != null && sectionTimetables.Count > 1)
            {
                sectionTimetables.First().IsFirst = true;
                sectionTimetables.Last().IsLast = true;

                //Set current
                foreach (PageSummaryItem child in sectionTimetables)
                {
                    Item current = child.InnerItem.Axes.SelectSingleItem(String.Format("descendant-or-self::*[@@id='{0}']", timetableItem.ID.ToString()));
                    if (current != null)
                    {
                        child.IsCurrent = true;
                    }
                }

                SecondLevelElements.DataSource = sectionTimetables;
                SecondLevelElements.DataBind();
            }

            PageSummaryItem timetableSectionItem = new PageSummaryItem(timetableItem.InnerItem.Parent);
            ClubTimetablesUrl = Sitecore.Links.LinkManager.GetItemUrl(timetableSectionItem);

            if (currentClub != null)
            {
                ClubName = currentClub.Clubname.Rendered;
                clubMemberPhone = currentClub.Memberstelephonenumber.Rendered;

                //Get enquiries link
                PageSummaryItem enqForm = new PageSummaryItem(Sitecore.Context.Database.GetItem(ItemPaths.EnquiryForm));
                if (enqForm != null)
                {
                    ClubEnquiriesUrl = enqForm.Url + "?sc_trk=enq&c=" + currentClub.InnerItem.ID.ToShortID();
                }

                //Set Book Online Link
                if (currentClub.GetCrmSystem() == ClubCrmSystemTypes.ClubCentric || currentClub.GetCrmSystem() == ClubCrmSystemTypes.Vision)
                {
                    //Show link
                    pnlBookOnline.Visible = true;
                    BookOnlineUrl = SitecoreHelper.GetMembershipLoginUrl(currentClub);
                }

                if (timetableItem.Showalert.Checked)
                {
                    string textToParse = timetableItem.Alerttext.Rendered;

                    Hashtable objTemplateVariables = new Hashtable();
                    objTemplateVariables.Add("SalesNumber", currentClub.Salestelephonenumber.Rendered);

                    Parser objParser = new Parser(objTemplateVariables);
                    objParser.SetTemplate(textToParse);
                    textToParse = objParser.Parse();

                    alert = @"<div class=""message""><p>" + textToParse + @"</p></div>";
                }
            }

            //What day are we rendering?
            int.TryParse(WebUtil.GetQueryString("day"), out day);

            timetableType = timetableItem.Type.Raw;

            Item settings = Sitecore.Context.Database.GetItem(ItemPaths.TimetableShared);
            if (settings != null)
            {
                TimetableSharedItem settingsItem = new TimetableSharedItem(settings);
                //TimetableUnavailableHeading.Text = settingsItem.Timetableunavailableheading.Text;
                TimetableUnavailableMessage.Text =
                    settingsItem.Mobiletimetableunavailabletext.Text.Replace("#clubMemberPhone#", clubMemberPhone);
            }

            try
            {
                //Only showing for one week from today (0)
                if (day >= 0 && day < 7)
                {

                    ClassContainer ClubClasses = Utility.GetClubTimetable(currentClub.ClubId.Raw);

                    if (ClubClasses != null)
                    {
                        //Set Previous Next Links
                        if (day == 0)
                        {
                            ltrNext.Text = @"<a href=""" + timetableItem.PageSummary.Url + @"?day=" + Convert.ToString(day + 1) + @""" class=""next"">" + Translate.Text("Tomorrow") + "</a>";
                        }
                        else if (day == 1)
                        {
                            ltrPrevious.Text = @"<a href=""" + timetableItem.PageSummary.Url + @"?day=" + Convert.ToString(day - 1) + @""" class=""previous"">" + Translate.Text("Today") + "</a>";
                            string nextDayName = DateTime.Now.AddDays(day + 1).DayOfWeek.ToString();
                            ltrNext.Text = @"<a href=""" + timetableItem.PageSummary.Url + @"?day=" + Convert.ToString(day + 1) + @""" class=""next"">" + Translate.Text(nextDayName) + "</a>";
                        }
                        else if (day == 6)
                        {

                            string previousDayName = DateTime.Now.AddDays(day - 1).DayOfWeek.ToString();
                            ltrPrevious.Text = @"<a href=""" + timetableItem.PageSummary.Url + @"?day=" + Convert.ToString(day - 1) + @""" class=""previous"">" + Translate.Text(previousDayName) + "</a>";
                        }
                        else
                        {
                            string previousDayName = DateTime.Now.AddDays(day - 1).DayOfWeek.ToString();
                            ltrPrevious.Text = @"<a href=""" + timetableItem.PageSummary.Url + @"?day=" + Convert.ToString(day - 1) + @""" class=""previous"">" + Translate.Text(previousDayName) + "</a>";
                            string nextDayName = DateTime.Now.AddDays(day + 1).DayOfWeek.ToString();
                            ltrNext.Text = @"<a href=""" + timetableItem.PageSummary.Url + @"?day=" + Convert.ToString(day + 1) + @""" class=""next"">" + Translate.Text(nextDayName) + "</a>";
                        }

                        //Set Date String
                        dateStr = StringHelper.GenerateDateStringMobile(DateTime.Now.AddDays(day));

                        foreach (Timetable item in ClubClasses.Timetables)
                        {
                            int classCount = 0;
                            if (item.Dayname != null)
                            {
                                //Check what day we are showing
                                if (item.Dayname.Equals(DateTime.Now.AddDays(day).DayOfWeek.ToString(), StringComparison.OrdinalIgnoreCase))
                                {

                                    //Check that classes exist for that timetable
                                    //Check which classes to display based on timetabletype
                                    switch (timetableType)
                                    {
                                        case TimetableTypes.General:
                                            venueHeading = Translate.Text("Studio");
                                            //Show everything apart from classes from Swim source
                                            foreach (Class classItem in item.Classes)
                                            {
                                                if (classItem.Source != TimetableSources.Swim)
                                                {

                                                    classCount++;
                                                    break;
                                                }
                                            }
                                            break;
                                        case TimetableTypes.Swim:
                                            //Do not show bookings panel if we are showing Swimming timetable
                                            pnlBookings.Visible = false;

                                            venueHeading = Translate.Text("Pool");
                                            //Only show classes from Swim source
                                            foreach (Class classItem in item.Classes)
                                            {
                                                if (classItem.Source == TimetableSources.Swim)
                                                {
                                                    classCount++;
                                                    break;
                                                }
                                            }
                                            break;
                                        default: break;
                                    }

                                    //Only add timetable to collection if classes exist
                                    if (classCount > 0)
                                    {
                                        //Bind Classes
                                        List<Class> tempItems = new List<Class>();

                                        //Check which classes to display based on timetabletype
                                        switch (timetableType)
                                        {
                                            case TimetableTypes.General:
                                                //Show everything apart from classes from Swim source
                                                foreach (Class classItem in item.Classes)
                                                {
                                                    if (classItem.Source != TimetableSources.Swim)
                                                    {
                                                        tempItems.Add(classItem);
                                                    }
                                                }
                                                break;
                                            case TimetableTypes.Swim:
                                                //Only show classes from Swim source
                                                foreach (Class classItem in item.Classes)
                                                {
                                                    if (classItem.Source == TimetableSources.Swim)
                                                    {
                                                        tempItems.Add(classItem);
                                                    }
                                                }
                                                break;
                                            default: break;
                                        }

                                        rptClass.DataSource = tempItems;
                                        rptClass.DataBind();

                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        pnlUnavailable.Visible = true;
                        pnlClasses.Visible = false;
                    }
                }

            }
            catch (Exception ex)
            {
                pnlUnavailable.Visible = true;
                pnlClasses.Visible = false;
            }

            //Set club last visited
            User objUser = new User();
            if (Session["sess_User"] != null)
            {
                objUser = (User)Session["sess_User"];
            }
            objUser.ClubLastVisitedID = currentClub.ClubId.Rendered;
            Session["sess_User"] = objUser;

            CookieHelper.AddClubsLastVisitedCookie(CookieKeyNames.ClubLastVisited, currentClub.ClubId.Rendered);

            //Add club name to page title
            string clubNameTitle = String.Format(" - {0}", currentClub.Clubname.Raw);
            clubNameTitle = HtmlRemoval.StripTagsCharArray(clubNameTitle);

            Page.Title = Page.Title + clubNameTitle;
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                //check if we have a valid club selected
                //Boolean blnClubSuccessfullySelected = txtClubGUID.Value != "";

                //check if we have a valid club selected
                Boolean blnClubSuccessfullySelected = clubFindSelect.SelectedIndex != 0;

                if (blnClubSuccessfullySelected == true)
                {
                    //Guid id = new Guid(
                    currentClub = (ClubItem)Sitecore.Context.Database.GetItem(clubFindSelect.SelectedValue);

                    if (currentClub != null)
                    {
                        //get managers info
                        List<ManagerItem> staffMembers = null;
                        if (currentClub.InnerItem.Axes.SelectItems(String.Format("descendant-or-self::*[@@tid = '{0}']", ManagerItem.TemplateId)) != null)
                        {
                            staffMembers = currentClub.InnerItem.Axes.SelectItems(String.Format("descendant-or-self::*[@@tid = '{0}']", ManagerItem.TemplateId)).ToList().ConvertAll(x => new ManagerItem(x));

                            manager = staffMembers.First();
                        }

                        //if (currentClub.GetCrmSystem() == ClubCrmSystemTypes.ClubCentric)
                        //{
                        //    //Data is sent to client via email
                        //    SendAdminEmail();
                        //}
                        //   else
                        //   {
                                //Data is sent to client via service
                        //       SendEnquiryDataService();
                        //   }

                        //Data is sent to client via service
                        SendEnquiryDataService();

                        //Save feedback to report DB
                        SaveDataToReportDB();

                        //Send confirmation email
                        SendConfirmationEmail();

                        //get user session
                        User objUser = new User();
                        if(Session["sess_User"] != null)
                        {
                            objUser = (User)Session["sess_User"];
                        }

                        if (!string.IsNullOrEmpty(objUser.ClubLastVisitedID))
                        {
                            ClubItem club = SitecoreHelper.GetClubOnClubId(objUser.ClubLastVisitedID);
                            if (club != null)
                            {
                                //Set url
                                Sitecore.Links.UrlOptions urlOptions = new Sitecore.Links.UrlOptions();
                                urlOptions.AlwaysIncludeServerUrl = true;
                                urlOptions.AddAspxExtension = true;
                                urlOptions.LanguageEmbedding = LanguageEmbedding.Never;

                                //Show club last visited link
                                System.Text.StringBuilder markupBuilder;
                                markupBuilder = new System.Text.StringBuilder();
                                markupBuilder.Append("<span>");
                                markupBuilder.Append(Translate.Text("You last visited") + " ");
                                markupBuilder.Append(@"<a href=""");
                                markupBuilder.Append(Sitecore.Links.LinkManager.GetItemUrl(club, urlOptions));
                                markupBuilder.Append(@""" class=""wl"">");
                                markupBuilder.Append(club.Clubname.Rendered);
                                markupBuilder.Append("</a></span>");

                                //ltrClubLastVisitedLink.Text = markupBuilder.ToString();
                            }
                        }

                        formToComplete.Visible = false;
                        formCompleted.Visible = true;

                        //System.Threading.Thread.Sleep(5000);
                        pnlForm.Update();
                    }
                }
                else
                {
                    cvClubName.IsValid = false;
                }
            }
            catch (Exception ex)
            {
                Log.Error(String.Format("Error processing club enquiry form {0}", ex.Message), this);
                mm.virginactive.common.EmailMessagingService.ErrorEmailNotification.SendMail(ex);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            club = SitecoreHelper.GetCurrentClub(Sitecore.Context.Item);
            Club current = new Club(club.InnerItem);
            //Set Esporta Flag or classic club flag
            if (current.IsClassic) //Classic club flag overrides exesporta
            {
                EsportaFlag.Text = String.Format(@"<span class=""prev-esporta""><span class=""prev-by"">{0}</span> {1}</span>", Translate.Text("by"), Translate.Text("VIRGIN ACTIVE CLASSIC"));
            } else if (club.GetCrmSystem() == ClubCrmSystemTypes.ClubCentric)
            {
                if (EsportaFlag != null)
                {
                    EsportaFlag.Text = @"<span class=""prev-esporta""> <span class=""prev-by"">" + Translate.Text("previously") + "</span> " + Translate.Text("ESPORTA") + "</span>";
                }
            }

            //Set club last visited
            User objUser = new User();
            if (Session["sess_User"] != null)
            {
                objUser = (User)Session["sess_User"];
            }
            if (objUser.ShowGallery)
            {
                HtmlGenericControl BodyTag = (HtmlGenericControl)this.Page.FindControl("BodyTag");
                string classNames = BodyTag.Attributes["class"] != null ? BodyTag.Attributes["class"] : "";
                BodyTag.Attributes.Add("class", classNames.Length > 0 ? classNames + " gallery_open" : "gallery_open");
            }
            objUser.ClubLastVisitedID = club.ClubId.Rendered;
            Session["sess_User"] = objUser;

            //Set club last visited cookie
            if (objUser.Preferences != null)
            {
                if (objUser.Preferences.PersonalisedCookies)
                {
                    CookieHelper.AddClubsLastVisitedCookie(CookieKeyNames.ClubLastVisited, club.ClubId.Rendered);
                }
            }

            //Retrieve CSS class
            string rawParameters = Attributes["sc_parameters"];
            NameValueCollection parameters = Sitecore.Web.WebUtil.ParseUrlParameters(rawParameters);
            if (!String.IsNullOrEmpty(parameters["OneColumn"]))
            {
                OneColumn = Convert.ToBoolean(parameters["OneColumn"]);
            }

            if (!String.IsNullOrEmpty(parameters["HasPanels"]))
            {
                Panels = Convert.ToBoolean(parameters["HasPanels"]) ? "-panels" : "";
            }

            //Add club name to page title
            string clubNameTitle = String.Format(" - {0}", club.Clubname.Raw);
            clubNameTitle = HtmlRemoval.StripTagsCharArray(clubNameTitle);

            Page.Title = Page.Title + clubNameTitle;

            this.Page.FindControl("ScriptPh").Controls.Add(new LiteralControl(@"<script>
                $(function(){
                    $('.va-overlay-link').vaOverlay({showMap:true });
                    $(""#carousel"").orbit({directionalNav:true, viewGallery:true });
                    $.va_init.functions.clubsSetup();
                });
                </script>"));
        }
        private void BindDropDownLists()
        {
            try
            {

                //Populate the club selector
                Item clubRoot = Sitecore.Context.Database.GetItem(ItemPaths.Clubs);
                ChildList clubLst = clubRoot.Children;
                Item[] clubs = clubLst.ToArray();

                //Populate the club selector
                List<ClubItem> clubList = clubs.ToList().ConvertAll(X => new ClubItem(X));
                clubList.RemoveAll(x => x.IsHiddenFromMenu());
                clubList.RemoveAll(x => x.IsPlaceholder.Checked && !x.ShowInClubSelect.Checked);
                findclub1.Items.Add(new ListItem(Translate.Text("Select a club"), ""));  //Added default first option

                foreach (Item club in clubList)
                {
                    ClubItem clubItem = new ClubItem(club);
                    if (clubItem != null)
                    {

                        if (!String.IsNullOrEmpty(clubItem.Clubname.Text))
                        {
                            string clubLabel = HtmlRemoval.StripTagsCharArray(clubItem.Clubname.Text).Trim();

                            ListItem lst = new ListItem(clubLabel, clubItem.ID.ToString());
                            lst.Attributes.Add("data-email", clubItem.Salesemail.Raw);
                            findclub1.Items.Add(lst);
                        }
                    }
                }

                // Populate No Employees dropdown
                //this.drpNoEmployees.Items.Clear();

                //string employeesItemsString = enquiryItem.Noofemployees.Raw.Replace("\r\n", ",");
                //employeesItemsString = employeesItemsString.Replace("\n", ",");
                //employeesItemsString = employeesItemsString.TrimEnd(',');
                //string[] employeesItems = employeesItemsString.Split(',');

                //foreach (string item in employeesItems)
                //{
                //    drpNoEmployees.Items.Add(new ListItem(item, item));
                //}
                //this.drpNoEmployees.Items.Insert(0, (Translate.Text("Select")));

                // Populate Existing Members dropdown
                //this.drpExistingMembers.Items.Clear();

                //string membersItemsString = enquiryItem.Existingmembers.Raw.Replace("\r\n", ",");
                //membersItemsString = membersItemsString.Replace("\n", ",");
                //membersItemsString = membersItemsString.TrimEnd(',');
                //string[] membersItems = membersItemsString.Split(',');

                //foreach (string item in membersItems)
                //{
                //    drpExistingMembers.Items.Add(new ListItem(item, item));
                //}
                //this.drpExistingMembers.Items.Insert(0, (Translate.Text("Select")));
            }
            catch (Exception ex)
            {
                Log.Error(String.Format("Error binding drop down lists: {0}", ex.Message), this);
                mm.virginactive.common.EmailMessagingService.ErrorEmailNotification.SendMail(ex);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                currentClub = SitecoreHelper.GetCurrentClub(feedbackItem.InnerItem);

                //Generate testimonial list
                if (feedbackItem.InnerItem.HasChildren)
                {
                    TestimonialPanel.Visible = true;
                    List<TestimonialItem> testimonials = feedbackItem.InnerItem.Children.ToList().ConvertAll(X => new TestimonialItem(X));
                    TestimonialList.DataSource = testimonials;
                    TestimonialList.DataBind();
                }
                else //no testimonials, hide this section
                {
                    TestimonialPanel.Visible = false;
                }

                //Find Club manager
                try
                {
                    manager = new ManagerItem(feedbackItem.InnerItem.Axes.SelectItems(String.Format("../descendant::*[@@tid='{0}']", ManagerItem.TemplateId))[0]);
                    if (manager != null)
                    {
                        ManagerPanel.Visible = true;
                    }
                }
                catch (Exception exe) {
                    Log.Error(String.Format("Could not fetch a club manager for club {1}: {0}", exe.Message, currentClub.Clubname.Raw), this);
                    mm.virginactive.common.EmailMessagingService.ErrorEmailNotification.SendMail(exe);
                }

                if (!Page.IsPostBack)
                {
                    BindDropDownLists();
                }

                string val = Translate.Text("Please enter {0}");
                rfvName.ErrorMessage = String.Format("<div class='error-msg'><p>{0}</p></div>", String.Format(val, Translate.Text("a name")));
                revName.ErrorMessage = String.Format("<div class='error-msg'><p>{0}</p></div>", String.Format(val, Translate.Text("a valid name")));
                rfvEmail.ErrorMessage = String.Format("<div class='error-msg'><p>{0}</p></div>", String.Format(val, Translate.Text("an email address")));
                revEmail.ErrorMessage = String.Format("<div class='error-msg'><p>{0}</p></div>", String.Format(val, Translate.Text("a valid email address")));
                rfvPhone.ErrorMessage = String.Format("<div class='error-msg'><p>{0}</p></div>", String.Format(val, Translate.Text("a phone number")));
                revPhone.ErrorMessage = String.Format("<div class='error-msg'><p>{0}</p></div>", String.Format(val, Translate.Text("a valid phone number")));
                rfvComments.ErrorMessage = String.Format("<div class='error-msg'><p>{0}</p></div>", String.Format(val, Translate.Text("your comments")));
                revEmail.ValidationExpression = Settings.EmailAddressRegularExpression;
                revPhone.ValidationExpression = Settings.PhoneNumberRegularExpression;
                revName.ValidationExpression = Settings.NameRegularExpression;

            }
            catch (Exception ex)
            {
                Log.Error(String.Format("Error generating Club feedback form items: {0}", ex.Message), this);
                mm.virginactive.common.EmailMessagingService.ErrorEmailNotification.SendMail(ex);
            }

            this.Page.FindControl("ScriptPh").Controls.Add(new LiteralControl(@"<script>
                $(function(){
                    $.va_init.functions.setupForms();
                });
                </script>"));
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                //check if we have a valid club selected
                Boolean blnClubSuccessfullySelected = clubs.Count > 0;

                if (blnClubSuccessfullySelected == true)
                {
                    //string[] clubs = txtClubGUID.Value.Split('|');
                    currentClubs = new List<ClubItem>();
                    foreach (string club in clubs)
                    {
                        if (club != "")
                        {
                            bool clubExists = false;
                            //Check for duplicates
                            foreach (ClubItem existingClubs in currentClubs)
                            {
                                if (existingClubs.ID.ToString() == club)
                                {
                                    clubExists = true;
                                }
                            }
                            if (clubExists == false)
                            {
                                currentClubs.Add((ClubItem)Sitecore.Context.Database.GetItem(Server.UrlDecode(club)));
                            }
                        }
                    }

                    if (currentClubs.Count > 0 && currentClubs[0] != null)
                    {
                        foreach (ClubItem club in currentClubs)
                        {
                            clubNames += HtmlRemoval.StripTagsCharArray(club.Clubname.Rendered).Trim() + ", ";
                        }
                        if (clubNames.LastIndexOf(",") != -1)
                        {
                            clubNames = clubNames.Substring(0, clubNames.LastIndexOf(","));
                        }

                        //set current club as first club in the collection
                        currentClub = currentClubs[0];
                        //get managers info
                        List<ManagerItem> staffMembers = null;
                        if (currentClub.InnerItem.Axes.SelectItems(String.Format("descendant-or-self::*[@@tid = '{0}']", ManagerItem.TemplateId)) != null)
                        {
                            staffMembers = currentClub.InnerItem.Axes.SelectItems(String.Format("descendant-or-self::*[@@tid = '{0}']", ManagerItem.TemplateId)).ToList().ConvertAll(x => new ManagerItem(x));
                            manager = staffMembers.First();
                        }
                        else
                        {
                            Log.Error(String.Format("No club manager exists for club: {0}", currentClub.Clubname.Raw), this);
                        }

                        //Send data to service
                        SendEnquiryDataService();

                        //Save feedback to report DB
                        SaveDataToReportDB();

                        //Send confirmation email
                        SendConfirmationEmail();

                        //get user session
                        User objUser = new User();
                        if (Session["sess_User"] != null)
                        {
                            objUser = (User)Session["sess_User"];
                        }

                        if (!string.IsNullOrEmpty(objUser.ClubLastVisitedID))
                        {
                            ClubItem club = SitecoreHelper.GetClubOnClubId(objUser.ClubLastVisitedID);
                            if (club != null)
                            {
                                //Set url
                                Sitecore.Links.UrlOptions urlOptions = new Sitecore.Links.UrlOptions();
                                urlOptions.AlwaysIncludeServerUrl = true;
                                urlOptions.AddAspxExtension = true;
                                urlOptions.LanguageEmbedding = LanguageEmbedding.Never;

                                //Show club last visited link
                                System.Text.StringBuilder markupBuilder;
                                markupBuilder = new System.Text.StringBuilder();
                                markupBuilder.Append("<span>");
                                markupBuilder.Append(Translate.Text("You last visited") + " ");
                                markupBuilder.Append(@"<a href=""");
                                markupBuilder.Append(Sitecore.Links.LinkManager.GetItemUrl(club, urlOptions));
                                markupBuilder.Append(@""" class=""wl"">");
                                markupBuilder.Append(club.Clubname.Rendered);
                                markupBuilder.Append("</a></span>");

                                //ltrClubLastVisitedLink.Text = markupBuilder.ToString();
                            }
                        }

                        formToComplete.Visible = false;
                        formCompleted.Visible = true;
                        pnlForm.Update();
                    }
                }
                else
                {
                    //cvClubName.IsValid = false;
                }
            }
            catch (Exception ex)
            {
                Log.Error(String.Format("Error processing club enquiry form {0}", ex.Message), this);
                mm.virginactive.common.EmailMessagingService.ErrorEmailNotification.SendMail(ex);
            }
        }
        private void SetPage()
        {
            try
            {

                //Get child carousel modules
                if (currentItem.InnerItem.HasChildren || currentCampaign.InnerItem.HasChildren)
                {
                    //Find Modules
                    List<ModuleItem> ModuleList = new List<ModuleItem>();

                    //Check if we have modules for the current campaign page
                    if (currentItem.InnerItem.Axes.SelectItems(String.Format("child::*[@@tid='{0}']", ModuleItem.TemplateId)) != null)
                    {
                        ModuleList.AddRange(currentItem.InnerItem.Axes.SelectItems(String.Format("child::*[@@tid='{0}']", ModuleItem.TemplateId)).ToList().ConvertAll(Y => new ModuleItem(Y)));
                    }

                    //Check if we have shared modules
                    if (currentCampaign.InnerItem.Axes.SelectItems(String.Format("child::*[@@tid='{0}']", ModuleItem.TemplateId)) != null)
                    {
                        ModuleList.AddRange(currentCampaign.InnerItem.Axes.SelectItems(String.Format("child::*[@@tid='{0}']", ModuleItem.TemplateId)).ToList().ConvertAll(Y => new ModuleItem(Y)));
                    }

                    if (ModuleList.Count > 0)
                    {
                        ModuleList.First().IsFirst = true;

                        CarouselPanels.DataSource = ModuleList;
                        CarouselPanels.DataBind();

                        CaptionPanels.DataSource = ModuleList;
                        CaptionPanels.DataBind();

                        OverlayPanels.DataSource = ModuleList;
                        OverlayPanels.DataBind();
                    }
                }

                // Populate Enquiry dropdown
                drpHowDidYouFindUs.Items.Clear();

                EnquiryFormItem enquiryItem = Sitecore.Context.Database.GetItem(ItemPaths.EnquiryForm);

                string queryItemsString = enquiryItem.Querytypes.Raw.Replace("\r\n", ",");
                queryItemsString = queryItemsString.Replace("\n", ",");
                queryItemsString = queryItemsString.TrimEnd(',');
                string[] queryItems = queryItemsString.Split(',');

                //drpHowDidYouFindUs.Items.Add(new ListItem(Translate.Text("Select"), ""));
                foreach (string item in queryItems)
                {
                    drpHowDidYouFindUs.Items.Add(new ListItem(item, item));
                }

                ListItem itm = new ListItem(Translate.Text("Select"), Translate.Text("default"));
                itm.Selected = true;
                drpHowDidYouFindUs.Items.Insert(0, itm);

                //Item clubRoot = Sitecore.Context.Database.GetItem(ItemPaths.Clubs);
                //ChildList clubLst = clubRoot.Children;
                //Item[] clubs = clubLst.ToArray();

                ////Populate the club selector
                //List<ClubItem> clubList = clubs.ToList().ConvertAll(X => new ClubItem(X));
                //clubList.RemoveAll(x => x.IsHiddenFromMenu());
                //clubList.RemoveAll(x => x.IsPlaceholder.Checked && !x.ShowInClubSelect.Checked);

                List<ClubItem> clubs = null;

                if (currentCampaign.CampaignBase.Usecustomclublist.Checked)
                {
                    //Use a custom list of clubs
                    clubs = currentCampaign.CampaignBase.Customclublist.ListItems.ConvertAll(X => new ClubItem(X));
                }
                else
                {
                    //Use a custom list of clubs
                    Item clubRoot = Sitecore.Context.Database.GetItem(ItemPaths.Clubs);
                    ChildList clubLst = clubRoot.Children;
                    clubs = clubLst.ToList().ConvertAll(X => new ClubItem(X));
                    clubs.RemoveAll(x => x.IsHiddenFromMenu());
                    clubs.RemoveAll(x => x.IsPlaceholder.Checked && !x.ShowInClubSelect.Checked);
                }

                clubFindSelect.Items.Add(new ListItem(Translate.Text("Select a club"), ""));

                foreach (Item club in clubs)
                {
                    ClubItem clubItem = new ClubItem(club);
                    if (clubItem != null)
                    {
                        if (!String.IsNullOrEmpty(clubItem.Clubname.Text))
                        {
                            string clubLabel = HtmlRemoval.StripTagsCharArray(clubItem.Clubname.Text).Trim();

                            clubFindSelect.Items.Add(new ListItem(clubLabel, clubItem.ID.ToString()));

                            //ListItem lst = new ListItem(clubLabel, clubItem.ID.ToString(), false);
                            //lst.Attributes.Add("data-email", clubItem.Salesemail.Raw);
                            //clubFindSelect.Items.Add(lst);
                        }
                    }
                }

                //Add dynamic content to header
                HtmlHead head = (HtmlHead)Page.Header;

                //Add Open Tag
                if (Session["sess_User"] != null)
                {
                    User objUser = (User)Session["sess_User"];
                    if (objUser.Preferences != null)
                    {
                        if (objUser.Preferences.MarketingCookies && objUser.Preferences.MetricsCookies)
                        {
                            head.Controls.Add(new LiteralControl(OpenTagHelper.OpenTagVirginActiveUK));
                        }
                    }
                }

                //Add Page Title
                System.Text.StringBuilder markupBuilder = new System.Text.StringBuilder();

                HtmlTitle title = (HtmlTitle)Page.FindControl("title");
                title.Text = currentItem.PageSummary.Browserpagetitle.Raw + " | " + Translate.Text("Virgin Active");
                markupBuilder.Append(@"<meta name='description' content='" + currentItem.PageSummary.Pagedescription + "'>");
                markupBuilder.Append(@"<meta name='viewport' content='width=1020'>");
                markupBuilder.Append(@"<link rel='apple-touch-icon' href='/virginactive/img/apple-touch-icon.png'>");
                markupBuilder.Append(@"<link rel='shortcut icon' href='/virginactive/images/favicon.ico'>");
                markupBuilder.Append(@"<link rel='stylesheet' href='/virginactive/css/campaign.css' type='text/css' />");
                markupBuilder.Append(@"<link rel='stylesheet' href='/virginactive/css/fonts.css' type='text/css' />");
                markupBuilder.Append(@"<link rel='stylesheet' href='/virginactive/css/cookies.css' type='text/css' />");

                head.Controls.Add(new LiteralControl(markupBuilder.ToString()));

            }
            catch (Exception ex)
            {
                Log.Error(String.Format("Error loading campaign page: {0}", ex.Message), this);
                mm.virginactive.common.EmailMessagingService.ErrorEmailNotification.SendMail(ex);
            }
        }
        private void BindDropDownLists()
        {
            try
            {
                //If this form is being called froma  club area, we will get a ShortGuid of the
                //originating club within the QS
                string clubQry = String.Empty;
                if (WebUtil.GetQueryString("c") != null)
                {
                    clubQry = WebUtil.GetQueryString("c");
                }

                Item clubRoot = Sitecore.Context.Database.GetItem(ItemPaths.Clubs);
                ChildList clubLst = clubRoot.Children;
                Item[] clubs = clubLst.ToArray();

                //Populate the club selector
                List<ClubItem> clubList = clubs.ToList().ConvertAll(X => new ClubItem(X));
                clubList.RemoveAll(x => x.IsHiddenFromMenu());
                clubList.RemoveAll(x => x.IsPlaceholder.Checked && !x.ShowInClubSelect.Checked);
                clubFindSelect.Items.Add(new ListItem(Translate.Text("Select a club"), ""));

                /*
                //Sort clubs alphabetically
                clubList.Sort(delegate(ClubItem c1, ClubItem c2)
                {
                    return c1.Clubname.Raw.CompareTo(c2.Clubname.Raw);

                });*/

                foreach (Item club in clubList)
                {
                    ClubItem clubItem = new ClubItem(club);
                    if (clubItem != null)
                    {

                        bool isSelected = clubQry.Equals(clubItem.ID.ToShortID().ToString());

                        if (!String.IsNullOrEmpty(clubItem.Clubname.Text))
                        {
                            string clubLabel = HtmlRemoval.StripTagsCharArray(clubItem.Clubname.Text).Trim();

                            ListItem lst = new ListItem(clubLabel, clubItem.ID.ToString());
                            lst.Attributes.Add("data-email", clubItem.Salesemail.Raw);
                            clubFindSelect.Items.Add(lst);

                            if (isSelected)
                            {
                                clubFindSelect.SelectedValue = clubItem.ID.ToString();
                            }
                        }
                    }
                }

                // Populate Enquiry dropdown
                this.drpHowDidYouFindUs.Items.Clear();

                string queryItemsString = enquiryItem.Querytypes.Raw.Replace("\r\n", ",");
                queryItemsString = queryItemsString.Replace("\n", ",");
                queryItemsString = queryItemsString.TrimEnd(',');
                string[] queryItems = queryItemsString.Split(',');

                //drpHowDidYouFindUs.Items.Add(new ListItem(Translate.Text("Select"), ""));
                foreach (string item in queryItems)
                {
                    drpHowDidYouFindUs.Items.Add(new ListItem(item, item));
                }
                this.drpHowDidYouFindUs.Items.Insert(0, (Translate.Text("Select")));
            }
            catch (Exception ex)
            {
                Log.Error(String.Format("Error binding drop down lists {1}: {0}", ex.Message, currentClub.Clubname.Raw), this);
                mm.virginactive.common.EmailMessagingService.ErrorEmailNotification.SendMail(ex);
            }
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                if (Page.IsValid == true)
                {
                    //check if we have a valid club selected
                    Boolean blnClubSuccessfullySelected =  clubFindSelect.SelectedIndex != 0;

                    if (blnClubSuccessfullySelected == true)
                    {
                        //Guid id = new Guid(
                        currentClub = (ClubItem)Sitecore.Context.Database.GetItem(clubFindSelect.SelectedValue);

                        if (currentClub != null)
                        {

                            //Store Feedback Entitiy Details
                            Feedback objFeedback = new Feedback();

                            //Store Customer Entitiy Details
                            Customer objCustomer = new Customer();

                            string FirstName = "";
                            string Surname = "";

                            if (txtName.Value.IndexOf(" ") != -1)
                            {
                                FirstName = txtName.Value.Substring(0, txtName.Value.IndexOf(" ")).Trim();
                                Surname = txtName.Value.Substring(txtName.Value.IndexOf(" ") + 1).Trim();
                            }
                            else
                            {
                                FirstName = txtName.Value.Trim();
                            }

                            objCustomer.EmailAddress = txtEmail.Value;
                            objCustomer.Firstname = FirstName;
                            objCustomer.Surname = Surname;
                            objCustomer.HomeClubID = currentClub.ClubId.Rendered;
                            objCustomer.TelephoneNumber = txtPhone.Value;

                            objFeedback.Customer = objCustomer;
                            objFeedback.FeedbackSubject = currentCampaign.CampaignBase.Campaigntype.Raw;
                            objFeedback.FeedbackSubjectDetail = currentCampaign.CampaignBase.Campaignname.Rendered;
                            objFeedback.FeedbackTypeID = Convert.ToInt32(currentCampaign.CampaignBase.CampaignId.Rendered);
                            objFeedback.PrimaryClubID = currentClub.ClubId.Rendered;
                            objFeedback.SubmissionDate = DateTime.Now;

                            //Add Comment
                            Comment objComment = new Comment();

                            //objComment.CommentDetail = source.Items[source.SelectedIndex].Value;
                            objComment.CommentDetail = drpHowDidYouFindUs.SelectedValue;
                            objComment.CommentImageTypeID = Constants.CommentImageType.QuestionnaireAnswer;
                            objComment.SortOrder = 1;
                            objComment.Subject = Translate.Text("How did you hear about us?");

                            List<Comment> objComments = new List<Comment>();
                            objComments.Add(objComment);

                            objFeedback.Comments = objComments;

                            string connection = Sitecore.Configuration.Settings.GetSetting("ConnectionString_VirginActiveReports");
                            DataAccessLayer dal = new DataAccessLayer(connection);
                            int successFlag = dal.SaveFeedback(Context.User.Identity.Name, currentCampaign.DisplayName, objFeedback);

                            if (successFlag > 0)
                            {
                                //Data is sent to client via email
                                SendAdminEmail();

                                if (currentCampaign.CampaignBase.Isweblead.Checked == true)
                                {
                                    //Data is sent to client via service
                                    SendEnquiryDataService();
                                }

                                //get managers info
                                List<ManagerItem> staffMembers = null;
                                if (currentClub.InnerItem.Axes.SelectItems(String.Format("descendant-or-self::*[@@tid = '{0}']", ManagerItem.TemplateId)) != null)
                                {
                                    staffMembers = currentClub.InnerItem.Axes.SelectItems(String.Format("descendant-or-self::*[@@tid = '{0}']", ManagerItem.TemplateId)).ToList().ConvertAll(x => new ManagerItem(x));

                                    manager = staffMembers.First();
                                }

                                if (currentCampaign.CampaignBase.Sendconfirmationemail.Checked == true)
                                {
                                    //Data is sent to customer via email
                                    SendConfirmationEmail();
                                }

                                //imageStatic.Attributes.Add("style", "display:none;");
                                formToComplete.Attributes.Add("style", "display:none;");
                                pnlEnquiryPanel.Visible = false;
                                formCompleted.Visible = true;
                                formCompleted.Attributes.Add("style", "display:block;");
                                //ClearFormFields();
                                pnlForm.Update();
                            }
                            else
                            {
                                //imageStatic.Attributes.Add("style", "display:none;");
                                formToComplete.Attributes.Add("style", "display:block;");
                                formCompleted.Attributes.Add("style", "display:none;");
                                pnlForm.Update();

                                Log.Error(String.Format("Error storing campaign details"), this);
                            }
                        }
                        else
                        {
                            //imageStatic.Attributes.Add("style", "display:none;");
                            formToComplete.Attributes.Add("style", "display:block;");
                            formCompleted.Attributes.Add("style", "display:none;");
                            pnlForm.Update();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(String.Format("Error processing club enquiry form {0}", ex.Message), this);
                mm.virginactive.common.EmailMessagingService.ErrorEmailNotification.SendMail(ex);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //THIS IS WHERE WE HIDE/SHOW COOKIE MESSAGE -N.B. User Session initialised and set in Header

            //Interorgate the request 'Do Not Track' settings.
            HttpContext objContext = HttpContext.Current;
            bool headerDoNotTrack = false;

            if (!string.IsNullOrEmpty(objContext.Request.Headers["DNT"]))
            {
                headerDoNotTrack = objContext.Request.Headers["DNT"] == "1" ? true : false;
            }

            User objUser = new User();

            //READ/SET COOKIE OPTIONS
            if (Session["sess_User"] == null)
            {
                newSession = true;
            }
            else
            {
                objUser = (User)Session["sess_User"];
            }

            //If this has not been set -we need to show the cookie message
            if (!headerDoNotTrack)
            {
                //Check if User Session object has been set -i.e. not first page load
                if (!newSession)
                {
                    //Have the cookie preferences been set?
                    if (objUser.Preferences == null)
                    {
                        //Show Cookie Preferences ribbon
                        CookieRibbon cookieDeclaration = Page.LoadControl("~/layouts/virginactive/CookieRibbon.ascx") as CookieRibbon;
                        RibbonPh.Controls.Add(cookieDeclaration);

                        string classNames = BodyTag.Attributes["class"] != null ? BodyTag.Attributes["class"] : "";
                        BodyTag.Attributes.Add("class", classNames.Length > 0 ? classNames + " cookie-show" : "cookie-show");
                    }
                }
                else
                {
                    //Seesion info not set (as it's a new session) -Check the 'Cookie Preferences Cookie' exists
                    if (string.IsNullOrEmpty(CookieHelper.GetOptInCookieValue(CookieKeyNames.MarketingCookies)))
                    {
                        //User has NOT stored settings
                        //Show Cookie Preferences ribbon
                        CookieRibbon cookieDeclaration = Page.LoadControl("~/layouts/virginactive/CookieRibbon.ascx") as CookieRibbon;
                        RibbonPh.Controls.Add(cookieDeclaration);

                        string classNames = BodyTag.Attributes["class"] != null ? BodyTag.Attributes["class"] : "";
                        BodyTag.Attributes.Add("class", classNames.Length > 0 ? classNames + " cookie-show" : "cookie-show");
                    }
                }
            }

            //READ/SET COOKIE OPTIONS
            if (newSession)
            {
                //New Session

                //Check if cookie preferences session cookie exists
                if (!string.IsNullOrEmpty(CookieHelper.GetOptInCookieValue(CookieKeyNames.MarketingCookies)))
                {
                    Preferences preferences = new Preferences();

                    preferences.MarketingCookies = CookieHelper.GetOptInCookieValue(CookieKeyNames.MarketingCookies) == "Y" ? true : false;
                    preferences.MetricsCookies = CookieHelper.GetOptInCookieValue(CookieKeyNames.MetricsCookies) == "Y" ? true : false;
                    preferences.PersonalisedCookies = CookieHelper.GetOptInCookieValue(CookieKeyNames.PersonalisedCookies) == "Y" ? true : false;
                    preferences.SocialCookies = CookieHelper.GetOptInCookieValue(CookieKeyNames.SocialCookies) == "Y" ? true : false;

                    //Store to session
                    objUser.Preferences = preferences;
                }
                else
                {
                    if (headerDoNotTrack)
                    {
                        //Set Preferences in User Session -default to N
                        Preferences preferences = new Preferences();

                        preferences.MarketingCookies = false;
                        preferences.MetricsCookies = false;
                        preferences.PersonalisedCookies = false;
                        preferences.SocialCookies = false;

                        objUser.Preferences = preferences;

                        //Set Cookie Preferences Cookie
                        CookieHelper.AddUpdateOptInCookie(CookieKeyNames.MarketingCookies, "N");
                        CookieHelper.AddUpdateOptInCookie(CookieKeyNames.MetricsCookies, "N");
                        CookieHelper.AddUpdateOptInCookie(CookieKeyNames.PersonalisedCookies, "N");
                        CookieHelper.AddUpdateOptInCookie(CookieKeyNames.SocialCookies, "N");

                        //Delete Existing Personalisation Cookie
                        CookieHelper.DeleteCookie();
                    }
                }
            }

            //DEFAULT PREFERENCES IF NOT SET
            if (objUser.Preferences == null)
            {
                //Set preferences in User Session -default to Y
                Preferences preferences = new Preferences();

                preferences.MarketingCookies = true;
                preferences.MetricsCookies = true;
                preferences.PersonalisedCookies = true;
                preferences.SocialCookies = true;

                //Store to session
                objUser.Preferences = preferences;

                //Set Cookie Preferences Cookie -default to permission allowed
                CookieHelper.AddUpdateOptInCookie(CookieKeyNames.MarketingCookies, "Y");
                CookieHelper.AddUpdateOptInCookie(CookieKeyNames.MetricsCookies, "Y");
                CookieHelper.AddUpdateOptInCookie(CookieKeyNames.PersonalisedCookies, "Y");
                CookieHelper.AddUpdateOptInCookie(CookieKeyNames.SocialCookies, "Y");
            }

            //Save session
            Session["sess_User"] = objUser;

            CampaignItem cmp = new CampaignItem(Sitecore.Context.Item);

            if (!String.IsNullOrEmpty(cmp.CampaignBase.Termsandconditionslink.Raw))
            {
                privacy = new PageSummaryItem(cmp.CampaignBase.Termsandconditionslink.Item);
            }

            Item currentItem = Sitecore.Context.Item;
            PageSummaryItem item = new PageSummaryItem(currentItem);
            string canonicalTag = item.GetCanonicalTag();

            string metaDescription = item.GetMetaDescription();

            //Add page title //todo: add club name
            string title = Translate.Text("Virgin Active");
            string browserPageTitle = item.GetPageTitle();

            string section = Sitecore.Web.WebUtil.GetQueryString("section");

            if (!String.IsNullOrEmpty(section))
            {
                PageSummaryItem listing = null;
                if (currentItem.TemplateID.ToString() == ClassesListingItem.TemplateId)
                {
                    //Get classes listing browser page title
                    listing = Sitecore.Context.Database.GetItem(ItemPaths.SharedClasses + "/" + section);
                }
                else if (currentItem.TemplateID.ToString() == FacilitiesListingItem.TemplateId)
                {
                    //Get facility listing browser page title
                    listing = Sitecore.Context.Database.GetItem(ItemPaths.SharedFacilities + "/" + section);
                }

                if (listing != null)
                {
                    browserPageTitle = listing.GetPageTitle();
                    canonicalTag = String.IsNullOrEmpty(Request.QueryString["section"]) ? listing.GetCanonicalTag() : listing.GetCanonicalTag(Request.QueryString["section"]);
                    metaDescription = listing.GetMetaDescription();
                }
            }

            if (!String.IsNullOrEmpty(browserPageTitle))
            {
                title = String.Format("{0} | {1}", browserPageTitle, title);
            }

            Page.Title = title;
            //Add canonical
            Page.Header.Controls.Add(new Literal() { Text = canonicalTag });
            //Add meta description
            Page.Header.Controls.Add(new Literal() { Text = metaDescription });

            //Load OpenTag container -depending on cookie preferences

            if (!newSession)
            {
                //Add dynamic content to header
                HtmlHead head = (HtmlHead)Page.Header;

                if (objUser.Preferences != null)
                {
                    if (objUser.Preferences.MarketingCookies && objUser.Preferences.MetricsCookies)
                    {
                        //Have permission to load in OpenTag
                        head.Controls.Add(new LiteralControl(OpenTagHelper.OpenTagVirginActiveUK));
                    }
                }

                //LOAD IN SOCIAL OPEN GRAPH -if cookie preference allows

            }

            //Get club details
            if (!Page.IsPostBack)
            {
                Item landingItem =
                    Sitecore.Context.Item.Axes.SelectSingleItem(String.Format("ancestor-or-self::*[@@tid='{0}']",
                                                                              ClubMicrositeLandingItem.TemplateId));

                if (landingItem == null)
                {
                    return;
                }

                ClubMicrositeLandingItem club = new ClubMicrositeLandingItem(landingItem);

                ClubItem linkClub = new ClubItem(club.Club.Item);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            System.Text.StringBuilder markupBuilder = new System.Text.StringBuilder();

            //Redirect to club home
            Sitecore.Links.UrlOptions urlOptions = new Sitecore.Links.UrlOptions();
            urlOptions.AlwaysIncludeServerUrl = true;
            urlOptions.AddAspxExtension = false;
            urlOptions.LanguageEmbedding = LanguageEmbedding.Never;

            micrositeLanding = micrositeHome.InnerItem.Parent;

            if (micrositeLanding != null)
            {
                club = micrositeLanding.Club.Item;

                if (club != null)
                {
                    //Get opening hours
                    if (club.Openinghours.Rendered.Trim() != "")
                    {
                        //add opening hours details
                        markupBuilder.Append(@"<p class=""openingtimes"">");
                        markupBuilder.Append(club.Openinghours.Rendered);
                        markupBuilder.Append(@"</p>");

                        openingHours = markupBuilder.ToString();
                    }

                    //Get address

                    markupBuilder = new System.Text.StringBuilder();

                    markupBuilder.Append(club.Addressline1.Text);
                    markupBuilder.Append(!String.IsNullOrEmpty(club.Addressline2.Text) ? "<br />" + club.Addressline2.Text : "");
                    markupBuilder.Append(!String.IsNullOrEmpty(club.Addressline3.Text) ? "<br />" + club.Addressline3.Text : "");
                    markupBuilder.Append("<br />");
                    markupBuilder.Append(!String.IsNullOrEmpty(club.Addressline4.Text) ? club.Addressline4.Text + " " : "");
                    markupBuilder.Append(club.Postcode.Text);

                    Address.Text = markupBuilder.ToString();

                    //Get Club details

                    ClubName = club.Clubname.Rendered;
                    lng = club.Long.Raw;
                    lat = club.Lat.Raw;

                    //Get timetable link
                    if (micrositeHome.InnerItem.Axes.SelectSingleItem(String.Format(@"descendant-or-self::*[@@tid = '{0}']", MicrositeTimetableItem.TemplateId)) != null)
                    {
                        MicrositeTimetableItem timetableItem = new MicrositeTimetableItem(micrositeHome.InnerItem.Axes.SelectSingleItem(String.Format(@"descendant-or-self::*[@@tid = '{0}']", MicrositeTimetableItem.TemplateId)));
                        MicrositeTimetableLandingItem timetableSectionItem = new MicrositeTimetableLandingItem(timetableItem.InnerItem.Parent);
                        ClubTimetableUrl = Sitecore.Links.LinkManager.GetItemUrl(timetableSectionItem);
                    }
                    else
                    {
                        if (micrositeHome.InnerItem.Axes.SelectSingleItem(String.Format(@"descendant-or-self::*[@@tid = '{0}']", TimetableDownloadItem.TemplateId)) != null)
                        {
                            TimetableDownloadItem timetableDownloadItem = new TimetableDownloadItem(micrositeHome.InnerItem.Axes.SelectSingleItem(String.Format(@"descendant-or-self::*[@@tid = '{0}']", TimetableDownloadItem.TemplateId)));
                            ClubTimetableUrl = Sitecore.Links.LinkManager.GetItemUrl(timetableDownloadItem);
                        }
                    }

                    //Get enquiries link
                    PageSummaryItem enqForm = new PageSummaryItem(Sitecore.Context.Database.GetItem(ItemPaths.EnquiryForm));
                    if (enqForm != null)
                    {
                        ClubEnquiriesUrl = enqForm.Url + "?sc_trk=enq&c=" + club.InnerItem.ID.ToShortID();
                    }

                    //Get Media Items from Widget Container
                    List<FacilityModuleItem> facilities = GetDataSource(micrositeHome.InnerItem);
                    List<MediaItem> mediaItems = new List<MediaItem>();
                    if (facilities != null)
                    {
                        foreach (FacilityModuleItem facilityModule in facilities)
                        {
                            List<MediaItem> galleryItems = facilityModule.Imagegallery.ListItems.ConvertAll(x => new MediaItem(x));
                            if (galleryItems != null && galleryItems.Count > 0)
                            {
                                mediaItems.Add(galleryItems[0]);
                            }
                        }
                    }

                    if (mediaItems.Count > 0)
                    {
                        ImageList.DataSource = mediaItems;
                        ImageList.DataBind();
                    }

                    //Set club last visited
                    User objUser = new User();
                    if (Session["sess_User"] != null)
                    {
                        objUser = (User)Session["sess_User"];
                    }
                    objUser.ClubLastVisitedID = club.ClubId.Rendered;
                    Session["sess_User"] = objUser;

                    //Set club last visited cookie
                    //if (objUser.Preferences != null)
                    //{
                    //    if (objUser.Preferences.PersonalisedCookies)
                    //    {
                    CookieHelper.AddClubsLastVisitedCookie(CookieKeyNames.ClubLastVisited, club.ClubId.Rendered);
                    //    }
                    //}
                }
            }
        }