/// <summary>
    /// The tlbPath callback event handler.
    /// </summary>
    protected void tlbPath_CallBack(object sender, PXCallBackEventArgs e)
    {
        if (e.Command.Name == "AddFav" && PXSiteMap.CurrentNode != null)
        {
            Guid nodeID = PXSiteMap.CurrentNode.NodeID;
            if (!IsInFavorites(nodeID))
            {
                AddFavorite(screenTitle, nodeID);
            }
            else
            {
                PXDatabase.Delete <Favorite>(
                    new PXDataFieldRestrict("UserID", PXAccess.GetUserID()),
                    new PXDataFieldRestrict("SiteMapID", nodeID)
                    );
            }
            PXContext.Session.FavoritesExists["FavoritesExists"] = null;
            PXSiteMap.FavoritesProvider.Clear();

            // check if favorites exists
            using (PXDataRecord exist = PXDatabase.SelectSingle <Favorite>(
                       new PXDataField("UserID"), new PXDataFieldValue("UserID", PXAccess.GetUserID())))
            {
                e.Result = (exist == null) ? "0" : "1";
            }
        }
        else if (e.Command.Name == "ClearFilter")
        {
            var ds = PXPage.GetDefaultDataSource(this.Page);
            if (ds != null)
            {
                var action = ds.DataGraph.Actions[clearFilterCommand];
                if (action != null)
                {
                    action.Press();
                }
            }
            PXCallbackManager.RegisterJavaScript(
                "if (window['__px_alls'] && __px_alls(this) && __px_alls(this)['tlbPath'])__px_alls(this)['tlbPath'].items['clearFilter'].setVisible(false);");
        }
    }
Beispiel #2
0
    //---------------------------------------------------------------------------
    /// <summary>
    /// The page Load event handler.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        var ds = PXPage.GetDefaultDataSource(this.Page);

        if (ds != null && ds.HasActiveContext)
        {
            if (ControlHelper.IsReloadPage(this))
            {
                var ctx = ds.DataGraph.GetContextViewDescriptor();
                if (ctx != null)
                {
                    if (ctx.HeaderValues != null)
                    {
                        screenTitle = string.Join(" - ", ctx.HeaderValues).ToUpper();
                    }
                    if (this.Visible)
                    {
                        var cm = PXCallbackManager.GetInstance();
                        PXCallbackManager.RegisterJavaScript(
                            string.Format("px.elemByID('{0}').innerHTML = '{1}';", LabelScreen.ClientID, screenTitle));
                    }
                }
            }
            else
            {
                screenTitle = " ";
            }
        }

        if (!string.IsNullOrEmpty(screenTitle))
        {
            this.ScreenTitle = HttpUtility.HtmlDecode(screenTitle);
        }
        if (!Page.IsCallback)
        {
            Page.EnableViewState = false;
            RegisterSyncTreeVars();
        }
        if (!this.Visible)
        {
            return;
        }

        Page.ClientScript.RegisterClientScriptBlock(GetType(), "addToFavorites", "var addToFavorites=\"" + PXMessages.Localize(InfoMessages.AddToFavorites) + "\";", true);
        Page.ClientScript.RegisterClientScriptBlock(GetType(), "removeFromFavorites", "var removeFromFavorites=\"" + PXMessages.Localize(InfoMessages.RemoveFromFavorites) + "\";", true);
        if (!this.Page.IsCallback || ControlHelper.IsReloadPage(tlbPath))
        {
            InitHelpMenu();
            RearrangeAuditMenu();
        }

        if (!willShowWelcomePage && this.Request.RawUrl.IndexOf("CS100000.aspx", StringComparison.InvariantCultureIgnoreCase) < 0 &&
            this.Request.RawUrl.IndexOf("/soap/", StringComparison.InvariantCultureIgnoreCase) == -1 &&
            this.Request.RawUrl.IndexOf("/wiki/", StringComparison.InvariantCultureIgnoreCase) == -1)
        {
            if (!PXAccess.FeatureSetInstalled("PX.Objects.CS.FeaturesSet"))
            {
                PXSiteMapNode cs = PXSiteMap.Provider.FindSiteMapNodeByScreenID("CS100000");
                if (cs != null)
                {
                    string navigateUrl = ResolveUrl(cs.Url);
                    if (!Page.IsCallback)
                    {
                        Response.Redirect(navigateUrl);
                    }
                }
            }
        }

        string localPath = Request.Url.LocalPath;

        if (!PXUrl.IsMainPage(Request.RawUrl) && !Request.Url.Query.Contains("PopupPanel=On"))
        {
            if (!localPath.EndsWith("Default.aspx"))
            {
                string lastUrl = (string)PXContext.Session["LastUrl"];
                if (String.IsNullOrEmpty(lastUrl) || lastUrl.EndsWith("Default.aspx"))
                {
                    Controls.Add(new LiteralControl("<script  type=\"text/javascript\">try { window.top.lastUrl=null; } catch (ex) {}</script>\n"));
                }
            }
            PXContext.Session.SetString("LastUrl", Request.RawUrl);
        }

        if (!Page.IsPostBack && !String.IsNullOrEmpty(ScreenID))
        {
            PX.Data.PXAuditJournal.Register(ScreenID);
        }

        if (!string.IsNullOrEmpty(screenTitle))
        {
            string relPath = ResolveUrl(Request.RawUrl);
            string url     = ResolveUrl(Request.RawUrl);
            LabelScreen.HRef = (Page != null && Page.GetType().Name == "wiki_showwiki_aspx") ? PXSessionStateStore.GetSessionUrl(HttpContext.Current, url) : url;

            if (PXSiteMap.CurrentNode != null && PXList.Provider.HasList(PXSiteMap.CurrentNode.ScreenID))
            {
                string        listScreenID = PXList.Provider.GetListID(PXSiteMap.CurrentNode.ScreenID);
                PXSiteMapNode listNode     = PXSiteMap.Provider.FindSiteMapNodeByScreenID(listScreenID);
                if (listNode != null)
                {
                    LabelScreen.HRef         = ResolveUrl(listNode.Url);
                    LabelScreen.ServerClick += (o, args) =>
                    {
                        PXList.Provider.SetCurrentSearches(PXSiteMap.CurrentNode.ScreenID, null);
                        Response.Redirect(ControlHelper.FixHideScriptUrl(PXPageCache.FixPageUrl(ResolveUrl(listNode.Url)), false));
                    };
                }
            }
            if (screenUrl != null)
            {
                LabelScreen.HRef = screenUrl;
            }

            this.ScreenTitle = screenTitle;
        }

        if (!Page.IsCallback)
        {
            Page.ClientScript.RegisterClientScriptBlock(GetType(), "toolbarNum", "var __toolbarID=\"" + this.tlbTools.ClientID + "\";", true);
        }
        if (ControlHelper.IsReloadPage(this))
        {
            SharedColumnSettings.SaveGrids();
        }
    }