protected void Page_Load(object sender, EventArgs e)
    {
        // Check UI element
        var elementName = IsMultiStoreConfiguration ? "Tools.Ecommerce.Invoice" : "Configuration.Invoice";

        CheckUIElementAccessHierarchical(ModuleName.ECOMMERCE, elementName);

        var actions = CurrentMaster.HeaderActions;

        // Save action
        actions.ActionsList.Add(new SaveAction
        {
            CommandName = "lnksave_click"
        });

        // Show "Copy from global" link when not configuring global invoice.
        if (ConfiguredSiteID != 0)
        {
            actions.ActionsList.Add(new HeaderAction
            {
                Text          = GetString("com.InvoiceFromGlobal"),
                OnClientClick = "return ConfirmCopyFromGlobal();",
                CommandName   = "copyFromGlobal",
                ButtonStyle   = ButtonStyle.Default
            });

            // Register javascript to confirm generate
            string script = "function ConfirmCopyFromGlobal() {return confirm(" + ScriptHelper.GetString(GetString("com.ConfirmInvoiceFromGlobal")) + ");}";
            ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ConfirmCopyFromGlobal", ScriptHelper.GetScript(script));
        }

        actions.ActionPerformed += HeaderActions_ActionPerformed;

        if (!RequestHelper.IsPostBack())
        {
            // Read the invoice
            invoiceTemplate.Text = ECommerceSettings.InvoiceTemplate(ConfiguredSiteID);
        }

        // Show "using global settings" info message only if showing global store settings
        if ((ConfiguredSiteID == 0) && (SiteID != 0))
        {
            ShowInformation(GetString("com.UsingGlobalInvoice"));
        }
    }
    /// <summary>
    /// Checks invoice templates.
    /// </summary>
    private void CheckInvoiceTemplates()
    {
        if (InvoiceTemplateCheck)
        {
            string currentSite = string.Empty;

            // Check if the site is using global invoice template
            if (!ECommerceSettings.UseGlobalInvoice(CMSContext.CurrentSiteName))
            {
                currentSite = CMSContext.CurrentSiteName;
            }

            // Check invoice template
            if (string.IsNullOrEmpty(ECommerceSettings.InvoiceTemplate(currentSite)))
            {
                DisplayMessage("com.settingschecker.noinvoicetemplate");
            }
        }
    }
    /// <summary>
    /// Save button action.
    /// </summary>
    protected void HeaderActions_ActionPerformed(object sender, CommandEventArgs e)
    {
        switch (e.CommandName.ToLowerCSafe())
        {
        case "lnksave_click":
            CheckConfigurationModification();

            // Save template
            SettingsKeyInfoProvider.SetValue(ECommerceSettings.INVOICE_TEMPLATE, ConfiguredSiteID, invoiceTemplate.Text.Trim());

            ShowChangesSaved();

            break;

        case "copyfromglobal":
            // Read global invoice
            invoiceTemplate.Text = ECommerceSettings.InvoiceTemplate(null);

            break;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check UI element
        var elementName = IsMultiStoreConfiguration ? "Tools.Ecommerce.Invoice" : "Configuration.Invoice";

        CheckUIElementAccessHierarchical(ModuleName.ECOMMERCE, elementName);

        HeaderActions actions = CurrentMaster.HeaderActions;

        // Save action
        actions.ActionsList.Add(new SaveAction
        {
            CommandName = "lnksave_click"
        });

        // Show "Copy from global" link when not configuring global invoice.
        if (ConfiguredSiteID != 0)
        {
            actions.ActionsList.Add(new HeaderAction
            {
                Text          = GetString("com.InvoiceFromGlobal"),
                OnClientClick = "return ConfirmCopyFromGlobal();",
                CommandName   = "copyFromGlobal",
                ButtonStyle   = ButtonStyle.Default
            });

            // Register javascript to confirm generate
            string script = "function ConfirmCopyFromGlobal() {return confirm(" + ScriptHelper.GetString(GetString("com.ConfirmInvoiceFromGlobal")) + ");}";
            ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ConfirmCopyFromGlobal", ScriptHelper.GetScript(script));
        }

        actions.ActionPerformed += HeaderActions_ActionPerformed;

        htmlInvoiceTemplate.ResolverName      = "EcommerceResolver";
        macroSelectorElm.Resolver             = EcommerceResolvers.EcommerceResolver;
        macroSelectorElm.CKEditorID           = htmlInvoiceTemplate.ClientID;
        AttachmentList.CheckObjectPermissions = false;

        if (ConfiguredSiteInfo != null)
        {
            bool allowEdit = ECommerceContext.IsUserAuthorizedForPermission(EcommercePermissions.CONFIGURATION_MODIFY);
            if (allowEdit)
            {
                // Display attachments tab in media dialog
                htmlInvoiceTemplate.MediaDialogConfig.MetaFileObjectID   = ConfiguredSiteID;
                htmlInvoiceTemplate.MediaDialogConfig.MetaFileObjectType = SiteInfo.OBJECT_TYPE;
                htmlInvoiceTemplate.MediaDialogConfig.MetaFileCategory   = ObjectAttachmentsCategories.INVOICE;
                htmlInvoiceTemplate.MediaDialogConfig.HideAttachments    = false;
            }
            else
            {
                // Hide attachments tab in media dialog
                htmlInvoiceTemplate.MediaDialogConfig.HideAttachments = true;
            }

            // Attachment list
            AttachmentList.ObjectID   = ConfiguredSiteID;
            AttachmentList.ObjectType = SiteInfo.OBJECT_TYPE;
            AttachmentList.Category   = ObjectAttachmentsCategories.INVOICE;
            AttachmentList.SiteID     = ConfiguredSiteID;

            // Attachment list permissions
            AttachmentList.AllowEdit = allowEdit;
        }
        else
        {
            // Disable attachments for global invoice
            plcAttachments.Visible = false;
            htmlInvoiceTemplate.MediaDialogConfig.HideAttachments = true;
        }

        DisplayHelperTable();

        if (!RequestHelper.IsPostBack())
        {
            htmlInvoiceTemplate.ResolvedValue = String.Empty;
            // Configuring global invoice
            if (ConfiguredSiteID == 0)
            {
                // Show global invoice
                htmlInvoiceTemplate.ResolvedValue = ECommerceSettings.InvoiceTemplate(null);
            }
            else
            {
                // Show site-specific invoice
                if (ConfiguredSiteInfo != null)
                {
                    htmlInvoiceTemplate.ResolvedValue = ECommerceSettings.InvoiceTemplate(ConfiguredSiteInfo.SiteName);
                }
            }

            InitHTMLEditor();
        }

        // Show "using global settings" info message only if showing global store settings
        if ((ConfiguredSiteID == 0) && (SiteID != 0))
        {
            ShowInformation(GetString("com.UsingGlobalInvoice"));
        }
    }
    /// <summary>
    /// Save button action.
    /// </summary>
    protected void HeaderActions_ActionPerformed(object sender, CommandEventArgs e)
    {
        switch (e.CommandName.ToLowerCSafe())
        {
        case "lnksave_click":
            // Check permissions
            CheckConfigurationModification();

            // Check if template doesn't contains more editable regions with same name
            Hashtable eRegions = new Hashtable();

            int textStart    = 0;
            int editRegStart = htmlInvoiceTemplate.ResolvedValue.Trim().IndexOfCSafe("$$", textStart);

            while (editRegStart >= 0)
            {
                // End of region
                editRegStart += 2;
                textStart     = editRegStart;
                if (editRegStart < htmlInvoiceTemplate.ResolvedValue.Trim().Length - 1)
                {
                    int editRegEnd = htmlInvoiceTemplate.ResolvedValue.Trim().IndexOf("$$", editRegStart, StringComparison.Ordinal);
                    if (editRegEnd >= 0)
                    {
                        string   region = htmlInvoiceTemplate.ResolvedValue.Trim().Substring(editRegStart, editRegEnd - editRegStart);
                        string[] parts  = (region + ":" + ":").Split(':');

                        textStart = editRegEnd + 2;
                        try
                        {
                            string name = parts[0];
                            if (name.Trim() != "")
                            {
                                if (eRegions[name.ToLowerCSafe()] != null)
                                {
                                    break;
                                }

                                // Check if name is codename
                                if (!ValidationHelper.IsCodeName(name))
                                {
                                    break;
                                }
                                eRegions[name.ToLowerCSafe()] = 1;
                            }
                        }
                        catch
                        {
                        }
                    }
                }

                editRegStart = htmlInvoiceTemplate.ResolvedValue.Trim().IndexOfCSafe("$$", textStart);
            }

            // Save template
            string siteName = null;
            if (ConfiguredSiteInfo != null)
            {
                siteName = ConfiguredSiteInfo.SiteName;
            }
            SettingsKeyInfoProvider.SetValue(ECommerceSettings.INVOICE_TEMPLATE, siteName, htmlInvoiceTemplate.ResolvedValue.Trim());

            // Show message
            ShowChangesSaved();

            break;

        case "copyfromglobal":
            // Read global invoice
            htmlInvoiceTemplate.ResolvedValue = ECommerceSettings.InvoiceTemplate(null);

            break;
        }
    }
Example #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check permissions for CMS Desk -> Ecommerce
        if (!CMSContext.CurrentUser.IsAuthorizedPerUIElement("CMS.Ecommerce", "Configuration.Invoice"))
        {
            RedirectToCMSDeskUIElementAccessDenied("CMS.Ecommerce", "Configuration.Invoice");
        }

        // Pagetitle
        this.CurrentMaster.Title.TitleText     = GetString("InvoiceTemplate.HeaderCaption");
        this.CurrentMaster.Title.TitleImage    = GetImageUrl("CMSModules/CMS_Ecommerce/invoice.png");
        this.CurrentMaster.Title.HelpTopicName = "invoice";
        this.CurrentMaster.Title.HelpName      = "helpTopic";

        // New item link
        string[,] actions = new string[2, 9];
        actions[0, 0]     = HeaderActions.TYPE_SAVEBUTTON;
        actions[0, 1]     = GetString("general.save");
        actions[0, 2]     = null;
        actions[0, 3]     = null;
        actions[0, 4]     = null;
        actions[0, 5]     = GetImageUrl("CMSModules/CMS_Content/EditMenu/save.png");
        actions[0, 6]     = "lnksave_click";
        actions[0, 7]     = null;
        actions[0, 8]     = "true";

        // Show "Copy from global" link when not configuring global invoice.
        if (ConfiguredSiteID != 0)
        {
            actions[1, 0] = HeaderActions.TYPE_SAVEBUTTON;
            actions[1, 1] = GetString("com.InvoiceFromGlobal");
            actions[1, 2] = "return ConfirmCopyFromGlobal();";
            actions[1, 3] = null;
            actions[1, 4] = null;
            actions[1, 5] = GetImageUrl("CMSModules/CMS_Ecommerce/invoicefromglobal.png");
            actions[1, 6] = "copyFromGlobal";
            actions[1, 7] = String.Empty;
            actions[1, 8] = true.ToString();

            // Register javascript to confirm generate
            string script = "function ConfirmCopyFromGlobal() {return confirm(" + ScriptHelper.GetString(GetString("com.ConfirmInvoiceFromGlobal")) + ");}";
            ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ConfirmCopyFromGlobal", ScriptHelper.GetScript(script));
        }

        this.CurrentMaster.HeaderActions.LinkCssClass     = "ContentSaveLinkButton";
        this.CurrentMaster.HeaderActions.Actions          = actions;
        this.CurrentMaster.HeaderActions.ActionPerformed += new CommandEventHandler(HeaderActions_ActionPerformed);

        lblInsertMacro.Text       = GetString("macroselector.insertmacro") + ":";
        AttachmentTitle.TitleText = GetString("general.attachments");

        macroSelectorElm.Resolver   = EmailTemplateMacros.EcommerceResolver;
        macroSelectorElm.CKEditorID = htmlInvoiceTemplate.ClientID;

        // Init attachment storage
        if (ConfiguredSiteInfo != null)
        {
            AttachmentList.ObjectID   = ConfiguredSiteID;
            AttachmentList.ObjectType = SiteObjectType.SITE;
            AttachmentList.Category   = MetaFileInfoProvider.OBJECT_CATEGORY_INVOICE;
            AttachmentList.SiteID     = ConfiguredSiteID;

            // Permissions
            AttachmentList.AllowEdit = ECommerceContext.IsUserAuthorizedForPermission("ConfigurationModify");
            AttachmentList.CheckObjectPermissions = false;
        }
        else
        {
            plcAttachments.Visible = false;
        }

        DisplayHelperTable();

        if (!RequestHelper.IsPostBack())
        {
            htmlInvoiceTemplate.ResolvedValue = "";
            // Configuring global invoice
            if (ConfiguredSiteID == 0)
            {
                // Show global invoice
                htmlInvoiceTemplate.ResolvedValue = ECommerceSettings.InvoiceTemplate(null);
            }
            else
            {
                // Show site-specific invoice
                if (ConfiguredSiteInfo != null)
                {
                    htmlInvoiceTemplate.ResolvedValue = ECommerceSettings.InvoiceTemplate(ConfiguredSiteInfo.SiteName);
                }
            }

            InitHTMLEditor();
        }

        // Show "using global settings" info message only if showing global store settings
        if ((ConfiguredSiteID == 0) && (SiteID != 0))
        {
            lblGlobalInfo.Visible = true;
            lblGlobalInfo.Text    = GetString("com.UsingGlobalInvoice");
        }
    }
Example #7
0
    /// <summary>
    /// Save button action.
    /// </summary>
    protected void HeaderActions_ActionPerformed(object sender, CommandEventArgs e)
    {
        switch (e.CommandName.ToLower())
        {
        case "lnksave_click":
            // Check permissions
            CheckConfigurationModification();

            // Check if template doesn't contains more editable regions with same name
            Hashtable eRegions = new Hashtable();

            int count        = 0;
            int textStart    = 0;
            int editRegStart = htmlInvoiceTemplate.ResolvedValue.Trim().IndexOf("$$", textStart);

            while (editRegStart >= 0)
            {
                count++;

                // End of region
                editRegStart += 2;
                textStart     = editRegStart;
                if (editRegStart < htmlInvoiceTemplate.ResolvedValue.Trim().Length - 1)
                {
                    int editRegEnd = htmlInvoiceTemplate.ResolvedValue.Trim().IndexOf("$$", editRegStart);
                    if (editRegEnd >= 0)
                    {
                        string   region = htmlInvoiceTemplate.ResolvedValue.Trim().Substring(editRegStart, editRegEnd - editRegStart);
                        string[] parts  = (region + ":" + ":").Split(':');

                        textStart = editRegEnd + 2;
                        try
                        {
                            string name = parts[0];
                            if (name.Trim() != "")
                            {
                                if (eRegions[name.ToLower()] != null)
                                {
                                    break;
                                }

                                if (!ValidationHelper.IsCodeName(name))
                                {
                                    break;
                                }
                                eRegions[name.ToLower()] = 1;
                            }
                        }
                        catch
                        {
                        }
                    }
                }

                editRegStart = htmlInvoiceTemplate.ResolvedValue.Trim().IndexOf("$$", textStart);
            }

            if (IsValid)
            {
                if (ConfiguredSiteInfo != null)
                {
                    SettingsKeyProvider.SetValue(ConfiguredSiteInfo.SiteName + "." + ECommerceSettings.INVOICE_TEMPLATE, htmlInvoiceTemplate.ResolvedValue.Trim());
                }
                else
                {
                    SettingsKeyProvider.SetValue(ECommerceSettings.INVOICE_TEMPLATE, htmlInvoiceTemplate.ResolvedValue.Trim());
                }
                lblInfo.Visible = true;
                lblInfo.Text    = GetString("General.ChangesSaved");
            }
            break;

        case "copyfromglobal":
            // Read global invoice
            htmlInvoiceTemplate.ResolvedValue = ECommerceSettings.InvoiceTemplate(null);

            break;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        HeaderActions actions = CurrentMaster.HeaderActions;

        // Save action
        actions.ActionsList.Add(new SaveAction(this)
        {
            CommandName = "lnksave_click"
        });

        // Show "Copy from global" link when not configuring global invoice.
        if (ConfiguredSiteID != 0)
        {
            actions.ActionsList.Add(new HeaderAction()
            {
                ControlType   = HeaderActionTypeEnum.LinkButton,
                Text          = GetString("com.InvoiceFromGlobal"),
                OnClientClick = "return ConfirmCopyFromGlobal();",
                ImageUrl      = GetImageUrl("CMSModules/CMS_Ecommerce/invoicefromglobal.png"),
                CommandName   = "copyFromGlobal"
            });

            // Register javascript to confirm generate
            string script = "function ConfirmCopyFromGlobal() {return confirm(" + ScriptHelper.GetString(GetString("com.ConfirmInvoiceFromGlobal")) + ");}";
            ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ConfirmCopyFromGlobal", ScriptHelper.GetScript(script));
        }

        actions.ActionPerformed += new CommandEventHandler(HeaderActions_ActionPerformed);

        lblInsertMacro.Text       = GetString("macroselector.insertmacro") + ":";
        AttachmentTitle.TitleText = GetString("general.attachments");

        macroSelectorElm.Resolver             = EmailTemplateMacros.EcommerceResolver;
        macroSelectorElm.CKEditorID           = htmlInvoiceTemplate.ClientID;
        AttachmentList.CheckObjectPermissions = false;

        if (ConfiguredSiteInfo != null)
        {
            bool allowEdit = ECommerceContext.IsUserAuthorizedForPermission("ConfigurationModify");
            if (allowEdit)
            {
                // Display attachments tab in media dialog
                htmlInvoiceTemplate.MediaDialogConfig.MetaFileObjectID   = ConfiguredSiteID;
                htmlInvoiceTemplate.MediaDialogConfig.MetaFileObjectType = SiteObjectType.SITE;
                htmlInvoiceTemplate.MediaDialogConfig.MetaFileCategory   = MetaFileInfoProvider.OBJECT_CATEGORY_INVOICE;
                htmlInvoiceTemplate.MediaDialogConfig.HideAttachments    = false;
            }
            else
            {
                // Hide attachments tab in media dialog
                htmlInvoiceTemplate.MediaDialogConfig.HideAttachments = true;
            }

            // Attachment list
            AttachmentList.ObjectID   = ConfiguredSiteID;
            AttachmentList.ObjectType = SiteObjectType.SITE;
            AttachmentList.Category   = MetaFileInfoProvider.OBJECT_CATEGORY_INVOICE;
            AttachmentList.SiteID     = ConfiguredSiteID;

            // Attachment list permissions
            AttachmentList.AllowEdit = allowEdit;
        }
        else
        {
            // Disable attachments for global invoice
            plcAttachments.Visible = false;
            htmlInvoiceTemplate.MediaDialogConfig.HideAttachments = true;
        }

        DisplayHelperTable();

        if (!RequestHelper.IsPostBack())
        {
            htmlInvoiceTemplate.ResolvedValue = "";
            // Configuring global invoice
            if (ConfiguredSiteID == 0)
            {
                // Show global invoice
                htmlInvoiceTemplate.ResolvedValue = ECommerceSettings.InvoiceTemplate(null);
            }
            else
            {
                // Show site-specific invoice
                if (ConfiguredSiteInfo != null)
                {
                    htmlInvoiceTemplate.ResolvedValue = ECommerceSettings.InvoiceTemplate(ConfiguredSiteInfo.SiteName);
                }
            }

            InitHTMLEditor();
        }

        // Show "using global settings" info message only if showing global store settings
        if ((ConfiguredSiteID == 0) && (SiteID != 0))
        {
            ShowInformation(GetString("com.UsingGlobalInvoice"));
        }
    }