Ejemplo n.º 1
0
 public void ConvertToCart(Boolean debugMode = false, String storageType = "Cookie", string nameAppendix = "")
 {
     // only magers and editors allowed to edit orders
     if (UserController.Instance.GetCurrentUserInfo().IsInRole(StoreSettings.ManagerRole) ||
         UserController.Instance.GetCurrentUserInfo().IsInRole(StoreSettings.EditorRole) ||
         UserController.Instance.GetCurrentUserInfo().IsInRole("Administrators"))
     {
         AddAuditMessage("EDIT ORDER", "sys", UserController.Instance.GetCurrentUserInfo().Username, "False");
         PurchaseTypeCode = "CART";
         EditMode         = "E";
         var cartId   = base.SavePurchaseData();
         var cartData = new CartData(PortalId, "", cartId.ToString(""));              //create the client record (cookie)
         cartData.PurchaseInfo.SetXmlProperty("genxml/currentcartstage", "cartlist"); // make sure we start edit at cart stage.
         cartData.Save();
         if (StoreSettings.Current.DebugModeFileOut)
         {
             OutputDebugFile("debug_convertedorder.xml");
         }
     }
 }
Ejemplo n.º 2
0
        public void CopyToCart(Boolean debugMode = false, String storageType = "Cookie", string nameAppendix = "")
        {
            PurchaseTypeCode = "CART";
            EditMode         = "R";

            // reset order fields
            ShippedDate     = "";
            OrderStatus     = "010";
            TrackingCode    = "";
            InvoiceFileExt  = "";
            InvoiceFileName = "";
            InvoiceFilePath = "";
            PurchaseInfo.SetXmlProperty("genxml/audit", "");

            var cartId   = base.SavePurchaseData(true);
            var cartData = new CartData(PortalId, "", cartId.ToString(""));  //create the client record (cookie)

            cartData.Save();
            if (StoreSettings.Current.DebugModeFileOut)
            {
                OutputDebugFile("debug_copytocart.xml");
            }
        }
Ejemplo n.º 3
0
        public override TestOfData TestOfDataBinding(object sender, EventArgs e)
        {
            var rtnData = new TestOfData();
            rtnData.DataValue = null;
            rtnData.TestValue = null;
            var lc = (Literal)sender;
            var container = (IDataItemContainer)lc.NamingContainer;
            try
            {
                NBrightInfo info;

                ProductData prodData;
                CatProdXref xrefData;

                var xmlDoc = new XmlDocument();
                CartData currentcart;

                xmlDoc.LoadXml("<root>" + lc.Text + "</root>");
                var xmlNod = xmlDoc.SelectSingleNode("root/tag");

                if (container.DataItem != null && xmlNod != null && (xmlNod.Attributes != null && xmlNod.Attributes["function"] != null))
                {
                    rtnData.DataValue = "FALSE";

                    XmlNode nod;
                    var testValue = "";
                    if ((xmlNod.Attributes["testvalue"] != null)) testValue = xmlNod.Attributes["testvalue"].Value;

                    // check for setting key
                    var settingkey = "";
                    if ((xmlNod.Attributes["key"] != null)) settingkey = xmlNod.Attributes["key"].Value;

                    var role = "";
                    if ((xmlNod.Attributes["role"] != null)) role = xmlNod.Attributes["role"].Value;

                    var index = "";
                    if ((xmlNod.Attributes["index"] != null)) index = xmlNod.Attributes["index"].Value;

                    var modulekey = "";
                    if ((xmlNod.Attributes["modulekey"] != null)) modulekey = xmlNod.Attributes["modulekey"].Value;

                    var targetmodulekey = "";
                    if ((xmlNod.Attributes["targetmodulekey"] != null)) targetmodulekey = xmlNod.Attributes["targetmodulekey"].Value;

                    // do special tests for named fucntions
                    switch (xmlNod.Attributes["function"].Value.ToLower())
                    {
                        case "searchactive":
                            var navdata2 = new NavigationData(PortalSettings.Current.PortalId, targetmodulekey);
                            if (navdata2.Criteria == "") rtnData.DataValue = "FALSE";
                            else rtnData.DataValue = "TRUE";
                            break;
                        case "productcount":
                            var navdata = new NavigationData(PortalSettings.Current.PortalId, modulekey);
                            rtnData.DataValue = navdata.RecordCount;
                            break;
                        case "price":
                            rtnData.DataValue = GetFromPrice((NBrightInfo) container.DataItem);
                            break;
                        case "dealerprice":
                            rtnData.DataValue = GetDealerPrice((NBrightInfo) container.DataItem);
                            break;
                        case "saleprice":
                            rtnData.DataValue = GetSalePrice((NBrightInfo) container.DataItem);
                            break;
                        case "imgexists":
                            rtnData.DataValue = testValue;
                            nod = GenXmlFunctions.GetGenXmLnode(DataBinder.Eval(container.DataItem, _databindColumn).ToString(), "genxml/imgs/genxml[" + rtnData.DataValue + "]");
                            if (nod == null) rtnData.DataValue = "FALSE";
                            break;
                        case "modelexists":
                            rtnData.DataValue = testValue;
                            nod = GenXmlFunctions.GetGenXmLnode(DataBinder.Eval(container.DataItem, _databindColumn).ToString(), "genxml/models/genxml[" + rtnData.DataValue + "]");
                            if (nod == null) rtnData.DataValue = "FALSE";
                            break;
                        case "optionexists":
                            rtnData.DataValue = testValue;
                            nod = GenXmlFunctions.GetGenXmLnode(DataBinder.Eval(container.DataItem, _databindColumn).ToString(), "genxml/options/genxml[" + rtnData.DataValue + "]");
                            if (nod == null) rtnData.DataValue = "FALSE";
                            break;
                        case "isinstock":
                            if (IsInStock((NBrightInfo) container.DataItem))
                            {
                                rtnData.DataValue = "TRUE";
                                rtnData.TestValue = "TRUE";
                            }
                            break;
                        case "ismodelinstock":
                            if (IsModelInStock((NBrightInfo) container.DataItem))
                            {
                                rtnData.DataValue = "TRUE";
                                rtnData.TestValue = "TRUE";
                            }
                            break;
                        case "inwishlist":
                            var productid = DataBinder.Eval(container.DataItem, "ItemId").ToString();
                            if (Utils.IsNumeric(productid))
                            {
                                var listname = "ItemList";
                                if ((xmlNod.Attributes["listname"] != null)) listname = xmlNod.Attributes["listname"].Value;

                                var wl = new ItemListData(listname);
                                if (wl.IsInList(productid))
                                {
                                    rtnData.DataValue = "TRUE";
                                    rtnData.TestValue = "TRUE";
                                }
                            }
                            break;
                        case "isonsale":
                            var saleprice = GetSalePriceDouble((NBrightInfo) container.DataItem);
                            if (saleprice > 0)
                            {
                                rtnData.DataValue = "TRUE";
                                rtnData.TestValue = "TRUE";
                            }
                            break;
                        case "hasrelateditems":
                            info = (NBrightInfo) container.DataItem;
                            prodData = ProductUtils.GetProductData(info.ItemID, info.Lang);
                            if (prodData.GetRelatedProducts().Count > 0)
                            {
                                rtnData.DataValue = "TRUE";
                                rtnData.TestValue = "TRUE";
                            }
                            break;
                        case "hasdocuments":
                            info = (NBrightInfo) container.DataItem;
                            prodData = ProductUtils.GetProductData(info.ItemID, info.Lang);
                            if (prodData.Docs.Count > 0)
                            {
                                rtnData.DataValue = "TRUE";
                                rtnData.TestValue = "TRUE";
                            }
                            break;
                        case "haspurchasedocuments":
                            info = (NBrightInfo) container.DataItem;
                            prodData = ProductUtils.GetProductData(info.ItemID, info.Lang);
                            if (prodData.Docs.Select(i => i.GetXmlProperty("genxml/checkbox/chkpurchase") == "True").Any())
                            {
                                rtnData.DataValue = "TRUE";
                                rtnData.TestValue = "TRUE";
                            }
                            break;
                        case "hasproperty":
                            info = (NBrightInfo) container.DataItem;
                            xrefData = new CatProdXref();
                            if (xrefData.IsProductInCategory(info.ItemID,testValue))
                            {
                                rtnData.DataValue = "TRUE";
                                rtnData.TestValue = "TRUE";
                            }
                            break;
                        case "isincategory":
                            info = (NBrightInfo) container.DataItem;
                            xrefData = new CatProdXref();
                            if (xrefData.IsProductInCategory(info.ItemID,testValue))
                            {
                                rtnData.DataValue = "TRUE";
                                rtnData.TestValue = "TRUE";
                            }
                            break;
                        case "isdocpurchasable":
                            nod = GenXmlFunctions.GetGenXmLnode(DataBinder.Eval(container.DataItem, _databindColumn).ToString(), "genxml/docs/genxml[" + index + "]/hidden/docid");
                            if (nod != null)
                            {
                                info = (NBrightInfo) container.DataItem;
                                prodData = ProductUtils.GetProductData(info.ItemID, info.Lang);
                                if (prodData.Docs.Select(i => i.GetXmlProperty("genxml/checkbox/chkpurchase") == "True" && i.GetXmlProperty("genxml/hidden/docid") == nod.InnerText).Any())
                                {
                                    rtnData.DataValue = "TRUE";
                                    rtnData.TestValue = "TRUE";
                                }
                            }
                            break;
                        case "isdocpurchased":
                            nod = GenXmlFunctions.GetGenXmLnode(DataBinder.Eval(container.DataItem, _databindColumn).ToString(), "genxml/docs/genxml[" + index + "]/hidden/docid");
                            if (nod != null && Utils.IsNumeric(nod.InnerText))
                            {
                                var uInfo = UserController.GetCurrentUserInfo();
                                //[TODO: work out method of finding if user purchased document.]
                                //if (NBrightBuyV2Utils.DocHasBeenPurchasedByDocId(uInfo.UserID, Convert.ToInt32(nod.InnerText)))
                                //{
                                //    rtnData.DataValue = "TRUE";
                                //    rtnData.TestValue = "TRUE";
                                //}
                            }
                            break;
                        case "hasmodelsoroptions":
                            nod = GenXmlFunctions.GetGenXmLnode(DataBinder.Eval(container.DataItem, _databindColumn).ToString(), "genxml/models/genxml[2]/hidden/modelid");
                            if (nod != null && nod.InnerText != "")
                            {
                                rtnData.DataValue = "TRUE";
                                rtnData.TestValue = "TRUE";
                            }
                            if (rtnData.DataValue == "FALSE")
                            {
                                nod = GenXmlFunctions.GetGenXmLnode(DataBinder.Eval(container.DataItem, _databindColumn).ToString(), "genxml/options/genxml[1]/hidden/optionid");
                                if (nod != null && nod.InnerText != "")
                                {
                                    rtnData.DataValue = "TRUE";
                                    rtnData.TestValue = "TRUE";
                                }
                            }
                            break;
                        case "isproductincart":
                            var cartData = new CartData(PortalSettings.Current.PortalId);
                            info = (NBrightInfo) container.DataItem;
                            if (cartData.GetCartItemList().Select(i => i.GetXmlProperty("genxml/productid") == info.ItemID.ToString("")).Any())
                            {
                                rtnData.DataValue = "TRUE";
                                rtnData.TestValue = "TRUE";
                            }
                            break;
                        case "settings":
                            if (_settings != null && _settings.ContainsKey(settingkey) && _settings[settingkey] == testValue)
                            {
                                rtnData.DataValue = "TRUE";
                                rtnData.TestValue = "TRUE";
                            }
                            break;
                        case "debugmode":
                            if (StoreSettings.Current.DebugMode)
                            {
                                rtnData.DataValue = "TRUE";
                                rtnData.TestValue = "TRUE";
                            }
                            break;
                        case "isinrole":
                            if (CmsProviderManager.Default.IsInRole(role))
                            {
                                rtnData.DataValue = "TRUE";
                                rtnData.TestValue = "TRUE";
                            }
                            break;
                        case "issuperuser":
                            if (UserController.GetCurrentUserInfo().IsSuperUser)
                            {
                                rtnData.DataValue = "TRUE";
                                rtnData.TestValue = "TRUE";
                            }
                            break;
                        case "isuser":
                            if (UserController.GetCurrentUserInfo().UserID >= 0)
                            {
                                rtnData.DataValue = "TRUE";
                                rtnData.TestValue = "TRUE";
                            }
                            break;
                        case "isclientordermode":
                            currentcart = new CartData(PortalSettings.Current.PortalId);
                            if (currentcart.IsClientOrderMode())
                            {
                                rtnData.DataValue = "TRUE";
                                rtnData.TestValue = "TRUE";
                            }
                            break;
                        case "carteditmode":
                            currentcart = new CartData(PortalSettings.Current.PortalId);
                            var editmode = currentcart.GetInfo().GetXmlProperty("genxml/carteditmode");
                            if (editmode == testValue)
                            {
                                rtnData.DataValue = "TRUE";
                                rtnData.TestValue = "TRUE";
                            }
                            break;
                        case "iscartempty":
                            currentcart = new CartData(PortalSettings.Current.PortalId);
                            var l = currentcart.GetCartItemList();
                            if (!l.Any())
                            {
                                rtnData.DataValue = "TRUE";
                                rtnData.TestValue = "TRUE";
                            }
                            break;
                        case "hasshippingproviders":
                            var pluginData = new PluginData(PortalSettings.Current.PortalId);
                            var provList = pluginData.GetShippingProviders();
                            if (provList.Count > 1)
                            {
                                rtnData.DataValue = "TRUE";
                                rtnData.TestValue = "TRUE";
                            }
                            break;
                        case "profile":
                            var userInfo = UserController.GetCurrentUserInfo();
                            if (userInfo.UserID >= 0) rtnData.DataValue = userInfo.Profile.GetPropertyValue(settingkey);
                            break;
                        case "static":
                            break;
                        default:
                            rtnData.DataValue = null;
                            break;
                    }
                }
            }
            catch (Exception)
            {
                lc.Text = "";
            }
            return rtnData;
        }
Ejemplo n.º 4
0
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            // get setting via control params
            if (DisplayHeader != null && DisplayHeader == "") DisplayHeader = "minicartheader.html";
            if (DisplayBody != null && DisplayHeader == "") DisplayBody = "minicartbody.html";
            if (DisplayFooter != null && DisplayHeader == "") DisplayFooter = "minicartfooter.html";
            if (!String.IsNullOrEmpty(DisplayHeader) && !ModSettings.Settings().ContainsKey("txtdisplayheader")) ModSettings.Settings().Add("txtdisplayheader", DisplayHeader);
            if (!String.IsNullOrEmpty(DisplayBody) && !ModSettings.Settings().ContainsKey("txtdisplaybody")) ModSettings.Settings().Add("txtdisplaybody", DisplayBody);
            if (!String.IsNullOrEmpty(DisplayFooter) && !ModSettings.Settings().ContainsKey("txtdisplayfooter")) ModSettings.Settings().Add("txtdisplayfooter", DisplayFooter);
            if (!String.IsNullOrEmpty(PaymentTab) && !ModSettings.Settings().ContainsKey("PaymentTab")) ModSettings.Settings().Add("PaymentTab",PaymentTab );
            if (!String.IsNullOrEmpty(Themefolder) && !ModSettings.Settings().ContainsKey("themefolder")) ModSettings.Settings().Add("themefolder", Themefolder);

            _cartInfo = new CartData(PortalId);

            _addressData = new AddressData(_cartInfo.UserId.ToString(""));

            if (ModSettings.Get("themefolder") == "")  // if we don't have module setting jump out
            {
                rpDataH.ItemTemplate = new GenXmlTemplate("NO MODULE SETTINGS");
                return;
            }

            try
            {
                _templH = ModSettings.Get("txtdisplayheader");
                _templD = ModSettings.Get("txtdisplaybody");
                _templDfoot = ModSettings.Get("txtdisplaybodyfoot");
                _templF = ModSettings.Get("txtdisplayfooter");

                const string templAB = "cartbillingaddress.html";
                const string templAS = "cartshippingaddress.html";
                const string templS = "cartshipment.html";
                const string templE = "cartextra.html";
                const string templD = "cartdetails.html";

                carttype = ModSettings.Get("ddlcarttype");  // This is left for backward compatiblity with NBS_Cart module (now removed from install).

                if (carttype == "")
                {
                    // cart type is not a setting, so use the controlanme
                    if (ModuleConfiguration.DesktopModule.ModuleName == "NBS_MiniCart") carttype = "1";
                    if (ModuleConfiguration.DesktopModule.ModuleName == "NBS_FullCart") carttype = "3";
                    if (ModuleConfiguration.DesktopModule.ModuleName == "NBS_Checkout") carttype = "2";
                }

                if (carttype == "3" || carttype == "2") // check if we need to add cookie items
                {
                    _cartInfo.AddCookieToCart();
                    _cartInfo.Save();
                }
                if (!_cartInfo.GetCartItemList().Any() && (carttype == "3" || carttype == "2"))
                    _templH = "cartempty.html"; // check for empty cart
                else
                {
                    // Get Display Body
                    var rpDataTempl = ModCtrl.GetTemplateData(ModSettings, _templD, Utils.GetCurrentCulture(), DebugMode);
                    rpData.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(rpDataTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);

                    // Get Display Footer
                    var rpDataFTempl = ModCtrl.GetTemplateData(ModSettings, _templF, Utils.GetCurrentCulture(), DebugMode);
                    rpDataF.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(rpDataFTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);

                    // Get CartLayout
                    var layouttemplate = "checkoutlayout.html";
                    if (carttype == "3") layouttemplate = "fullcartlayout.html";
                    var checkoutlayoutTempl = ModCtrl.GetTemplateData(ModSettings, layouttemplate, Utils.GetCurrentCulture(), DebugMode);
                    checkoutlayout.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(checkoutlayoutTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);
                    _templateHeader = (GenXmlTemplate)checkoutlayout.ItemTemplate;

                }
                // Get Display Header
                var rpDataHTempl = ModCtrl.GetTemplateData(ModSettings, _templH, Utils.GetCurrentCulture(), DebugMode);

                rpDataH.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(rpDataHTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);

                // insert page header text
                NBrightBuyUtils.IncludePageHeaders(ModCtrl, ModuleId, Page, _templateHeader, ModSettings.Settings(), null, DebugMode);

                if (carttype == "2")
                {
                    // add any shiiping provider templates to the cart layout, so we can process any data required by them
                    rpShip.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(ModCtrl.GetTemplateData(ModSettings, templS, Utils.GetCurrentCulture(), DebugMode), ModSettings.Settings(), PortalSettings.HomeDirectory);
                    rpAddrB.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(ModCtrl.GetTemplateData(ModSettings, templAB, Utils.GetCurrentCulture(), DebugMode), ModSettings.Settings(), PortalSettings.HomeDirectory);
                    rpAddrS.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(ModCtrl.GetTemplateData(ModSettings, templAS, Utils.GetCurrentCulture(), DebugMode), ModSettings.Settings(), PortalSettings.HomeDirectory);

                    var checkoutextraTempl = ModCtrl.GetTemplateData(ModSettings, templE, Utils.GetCurrentCulture(), DebugMode);
                    checkoutextraTempl += GetShippingProviderTemplates();
                    rpExtra.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(checkoutextraTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);

                }

            }
            catch (Exception exc)
            {
                rpDataF.ItemTemplate = new GenXmlTemplate(exc.Message, ModSettings.Settings());
                // catch any error and allow processing to continue, output error as footer template.
            }
        }
Ejemplo n.º 5
0
        public void CopyToCart(Boolean debugMode = false, String storageType = "Cookie", string nameAppendix = "")
        {
            PurchaseTypeCode = "CART";
            EditMode = "R";

            // reset order fields
            ShippedDate = "";
            OrderStatus = "010";
            TrackingCode = "";
            InvoiceFileExt = "";
            InvoiceFileName = "";
            InvoiceFilePath = "";
            PurchaseInfo.SetXmlProperty("genxml/audit","");
            OrderNumber = "";

            var cartId = base.SavePurchaseData(true);
            var cartData = new CartData(PortalId,  "", cartId.ToString("")); //create the client record (cookie)

            cartData.Save();
            if (StoreSettings.Current.DebugModeFileOut) OutputDebugFile("debug_copytocart.xml");
        }
Ejemplo n.º 6
0
 public void ConvertToCart(Boolean debugMode = false, String storageType = "Cookie", string nameAppendix = "")
 {
     // only magers and editors allowed to edit orders
     if (UserController.Instance.GetCurrentUserInfo().IsInRole(StoreSettings.ManagerRole) ||
         UserController.Instance.GetCurrentUserInfo().IsInRole(StoreSettings.EditorRole) ||
         UserController.Instance.GetCurrentUserInfo().IsInRole("Administrators"))
     {
         AddAuditMessage("EDIT ORDER","sys",UserController.Instance.GetCurrentUserInfo().Username,"False");
         PurchaseTypeCode = "CART";
         EditMode = "E";
         var cartId = base.SavePurchaseData();
         var cartData = new CartData(PortalId, "", cartId.ToString("")); //create the client record (cookie)
         cartData.PurchaseInfo.SetXmlProperty("genxml/currentcartstage", "cartlist"); // make sure we start edit at cart stage.
         cartData.Save();
         if (StoreSettings.Current.DebugModeFileOut) OutputDebugFile("debug_convertedorder.xml");
     }
 }
Ejemplo n.º 7
0
 private string RecalculateCart(HttpContext context)
 {
     var strOut = "";
         var ajaxInfoList = GetAjaxInfoList(context);
         var currentcart = new CartData(PortalSettings.Current.PortalId);
         foreach (var ajaxInfo in ajaxInfoList)
         {
                 currentcart.MergeCartInputData(currentcart.GetItemIndex(ajaxInfo.GetXmlProperty("genxml/hidden/itemcode")), ajaxInfo);
         }
         currentcart.Save(StoreSettings.Current.DebugMode);
         strOut = "OK";
         return strOut;
 }
Ejemplo n.º 8
0
        protected void CtrlItemCommand(object source, RepeaterCommandEventArgs e)
        {
            var cArg = e.CommandArgument.ToString();
            var rtnTabId = TabId;
            var param = new string[4];

            if (_guidkey != "")
                param[0] = "ref=" + _guidkey; //using ref is url
            else
                if (_eid != "") param[0] = "eid=" + _eid; // using id in url

            if (_modkey != "") param[1] = "modkey=" + _modkey;

            if (_catname != "")
                param[2] = "catref=" + _catname; //using ref is url
            else
                if (_catid != "") param[2] = "catid=" + _catid; //using id is url

            // redirect to cart after add to basket is arg is redirect
            if (cArg.ToLower() == "redirect" && Utils.IsNumeric(StoreSettings.Current.CartTabId)) rtnTabId = StoreSettings.Current.CartTabId;
            if (cArg.ToLower() == "redirectnoparam" && Utils.IsNumeric(StoreSettings.Current.CartTabId))
            {
                rtnTabId = StoreSettings.Current.CartTabId;
                param[0] = "";
                param[1] = "";
                param[2] = "";
            }

            switch (e.CommandName.ToLower())
            {
                case "addtobasket":
                    var currentcart = new CartData(PortalId);
                    currentcart.AddItem(rpData, StoreSettings.Current.SettingsInfo, e.Item.ItemIndex, DebugMode);
                    currentcart.Save(StoreSettings.Current.DebugMode);
                    param[3] = "addcart=1";
                    Response.Redirect(Globals.NavigateURL(rtnTabId, "", param), true);
                    break;
                case "addalltobasket":
                    var currentcart2 = new CartData(PortalId);
                    foreach (RepeaterItem ri in rpData.Items)
                    {
                        currentcart2.AddItem(rpData, StoreSettings.Current.SettingsInfo, ri.ItemIndex, DebugMode);
                    }
                    currentcart2.Save(StoreSettings.Current.DebugMode);
                    param[3] = "addcart=1";
                    Response.Redirect(Globals.NavigateURL(rtnTabId, "", param), true);
                    break;
                case "addcookietobasket":
                    var currentcart3 = new CartData(PortalId);
                    currentcart3.AddCookieToCart();
                    currentcart3.Save(StoreSettings.Current.DebugMode);
                    param[3] = "addcart=1";
                    Response.Redirect(Globals.NavigateURL(rtnTabId, "", param), true);
                    break;
                case "docdownload":
                    var s = cArg.Split(':');
                    if (s.Length == 2)
                    {
                        var itemid = s[0];
                        var idx = s[1];
                        if (Utils.IsNumeric(idx) && Utils.IsNumeric(itemid))
                        {
                            var index = Convert.ToInt32(idx);
                            var prdData = ProductUtils.GetProductData(Convert.ToInt32(itemid), Utils.GetCurrentCulture());
                            if (prdData.Docs.Count >= index)
                            {
                                var docInfo = prdData.Docs[index -1];
                                var docFilePath = docInfo.GetXmlProperty("genxml/hidden/filepath");
                                var fileName = docInfo.GetXmlProperty("genxml/textbox/txtfilename"); ;
                                var fileExt = docInfo.GetXmlProperty("genxml/hidden/fileext");
                                var purchase = docInfo.GetXmlProperty("genxml/checkbox/chkpurchase");

                                if (fileName == "") fileName = "filename";
                                if (!fileName.EndsWith(fileExt)) fileName += fileExt;

                                if (purchase == "True")
                                {
                                    //[TODO: check if the document has been purchased]
                                    Utils.ForceDocDownload(docFilePath, fileName, Response);
                                }
                                else
                                {
                                    Utils.ForceDocDownload(docFilePath, fileName, Response);
                                }
                            }
                        }

                    }
                    break;
                case "printproduct":
                    param[0] = "eid=" + _eid;
                    param[1] = "print=printproduct";
                    param[2] = "template=printproduct.html";
                    Response.Redirect(Globals.NavigateURL(TabId,"", param), true);
                    break;
                default :
                    //check for any command providers.
                    var providerList = NBrightCore.providers.GenXProviderManager.ProviderList;
                    if (providerList != null)
                    {
                        foreach (var prov in providerList)
                        {
                            prov.Value.CtrlItemCommand(source, e);
                        }
                    }
                    Response.Redirect(Globals.NavigateURL(TabId, "", param), true);
                    break;
            }
        }
Ejemplo n.º 9
0
        private string AddToBasket(HttpContext context)
        {
            try
            {
                var strOut = "";
                var ajaxInfo = GetAjaxInfo(context);
                var settings = ajaxInfo.ToDictionary();

                if (settings.ContainsKey("productid"))
                {
                    if (!settings.ContainsKey("portalid")) settings.Add("portalid", PortalSettings.Current.PortalId.ToString("")); // aways make sure we have portalid in settings

                    var currentcart = new CartData(Convert.ToInt16(settings["portalid"]));
                    currentcart.AddAjaxItem(ajaxInfo, StoreSettings.Current.SettingsInfo,StoreSettings.Current.DebugMode);
                    currentcart.Save(StoreSettings.Current.DebugMode);
                    strOut = "OK";
                }

                return strOut;
            }
            catch (Exception ex)
            {
                return ex.ToString();
            }
        }
Ejemplo n.º 10
0
        public void ProcessRequest(HttpContext context)
        {
            #region "Initialize"

            var strOut = "";

            var paramCmd = Utils.RequestQueryStringParam(context, "cmd");
            var itemId = Utils.RequestQueryStringParam(context, "itemid");
            var ctlType = Utils.RequestQueryStringParam(context, "ctltype");
            var idXref = Utils.RequestQueryStringParam(context, "idxref");
            var xpathpdf = Utils.RequestQueryStringParam(context, "pdf");
            var xpathref = Utils.RequestQueryStringParam(context, "pdfref");
            var lang = Utils.RequestQueryStringParam(context, "lang");
            var language = Utils.RequestQueryStringParam(context, "language");
            var moduleId = Utils.RequestQueryStringParam(context, "mid");
            var moduleKey = Utils.RequestQueryStringParam(context, "mkey");
            var parentid = Utils.RequestQueryStringParam(context, "parentid");
            var entryid = Utils.RequestQueryStringParam(context, "entryid");
            var entryxid = Utils.RequestQueryStringParam(context, "entryxid");
            var catid = Utils.RequestQueryStringParam(context, "catid");
            var catxid = Utils.RequestQueryStringParam(context, "catxid");
            var templatePrefix = Utils.RequestQueryStringParam(context, "tprefix");
            var value = Utils.RequestQueryStringParam(context, "value");
            var itemListName = Utils.RequestQueryStringParam(context, "listname");
            if (itemListName == "") itemListName = "ItemList";
            if (itemListName == "*") itemListName = "ItemList";

            #region "setup language"

            // because we are using a webservice the system current thread culture might not be set correctly,
            SetContextLangauge(context);

            #endregion

            #endregion

            try
            {

                #region "Do processing of command"

                var intModuleId = 0;
                if (Utils.IsNumeric(moduleId)) intModuleId = Convert.ToInt32(moduleId);

                var objCtrl = new NBrightBuyController();

                var uInfo = new UserDataInfo(UserController.Instance.GetCurrentUserInfo().PortalID, intModuleId, objCtrl,
                    ctlType);
                strOut = "ERROR!! - No Security rights for current user!";
                switch (paramCmd)
                {
                    case "test":
                        strOut = "<root>" + UserController.Instance.GetCurrentUserInfo().Username + "</root>";
                        break;
                    case "setdata":
                        break;
                    case "deldata":
                        break;
                    //case "setcategoryadminform":
                    //    if (NBrightBuyUtils.CheckRights()) strOut = SetCategoryForm(context);
                    //    break;
                    case "getdata":
                        strOut = GetReturnData(context);
                        break;
                    case "additemlist":
                        if (Utils.IsNumeric(itemId))
                        {
                            var cw = new ItemListData(itemListName);
                            cw.Add(itemId);
                            strOut = cw.ItemList;
                        }
                        break;
                    case "removeitemlist":
                        if (Utils.IsNumeric(itemId))
                        {
                            var cw1 = new ItemListData(itemListName);
                            cw1.Remove(itemId);
                            strOut = cw1.ItemList;
                        }
                        break;
                    case "deleteitemlist":
                        var cw2 = new ItemListData(itemListName);
                        cw2.Delete();
                        strOut = "deleted";
                        break;
                    case "getproductselectlist":
                        strOut = GetProductList(context);
                        break;
                    case "getproductlist":
                        strOut = GetProductList(context);
                        break;
                    case "getcategoryproductlist":
                        strOut = GetCategoryProductList(context);
                        break;
                    case "setdefaultcategory":
                        if (NBrightBuyUtils.CheckRights()) strOut = SetDefaultCategory(context);
                        break;
                    case "deletecatxref":
                        if (NBrightBuyUtils.CheckRights()) strOut = DeleteCatXref(context);
                        break;
                    case "selectcatxref":
                        if (NBrightBuyUtils.CheckRights()) strOut = SelectCatXref(context);
                        break;
                    case "deleteallcatxref":
                        if (NBrightBuyUtils.CheckRights()) strOut = DeleteAllCatXref(context);
                        break;
                    case "copyallcatxref":
                        if (NBrightBuyUtils.CheckRights()) strOut = CopyAllCatXref(context);
                        break;
                    case "moveallcatxref":
                        if (NBrightBuyUtils.CheckRights()) strOut = CopyAllCatXref(context, true);
                        break;
                    case "editproduct":
                        if (NBrightBuyUtils.CheckRights()) strOut = GetProductGeneralData(context);
                        break;
                    case "productdescription":
                        if (NBrightBuyUtils.CheckRights()) strOut = GetProductDescription(context);
                        break;
                    case "productmodels":
                        if (NBrightBuyUtils.CheckRights()) strOut = GetProductModels(context);
                        break;
                    case "productoptions":
                        if (NBrightBuyUtils.CheckRights()) strOut = GetProductOptions(context);
                        break;
                    case "productoptionvalues":
                        if (NBrightBuyUtils.CheckRights()) strOut = GetProductOptionValues(context);
                        break;
                    case "productimages":
                        if (NBrightBuyUtils.CheckRights()) strOut = GetProductImages(context);
                        break;
                    case "productdocs":
                        if (NBrightBuyUtils.CheckRights()) strOut = GetProductDocs(context);
                        break;
                    case "productrelatedproducts":
                        if (NBrightBuyUtils.CheckRights()) strOut = GetProductModels(context);
                        break;
                    case "productcategories":
                        if (NBrightBuyUtils.CheckRights()) strOut = GetProductCategories(context);
                        break;
                    case "productisincategory":
                        if (NBrightBuyUtils.CheckRights()) strOut = ProductIsInCategory(context).ToString();
                        break;
                    case "productgroupcategories":
                        if (NBrightBuyUtils.CheckRights()) strOut = GetProductGroupCategories(context);
                        break;
                    case "productrelated":
                        if (NBrightBuyUtils.CheckRights()) strOut = GetProductRelated(context);
                        break;
                    case "productclients":
                        if (NBrightBuyUtils.CheckRights()) strOut = GetProductClients(context);
                        break;
                    case "getclientselectlist":
                        if (NBrightBuyUtils.CheckRights()) strOut = GetClientSelectList(context);
                        break;
                    case "addproductmodels":
                        if (NBrightBuyUtils.CheckRights()) strOut = AddProductModels(context);
                        break;
                    case "addproductoptions":
                        if (NBrightBuyUtils.CheckRights()) strOut = AddProductOptions(context);
                        break;
                    case "addproductoptionvalues":
                        if (NBrightBuyUtils.CheckRights()) strOut = AddProductOptionValues(context);
                        break;
                    case "addproductcategory":
                        if (NBrightBuyUtils.CheckRights()) strOut = AddProductCategory(context);
                        break;
                    case "addproductgroupcategory":
                        if (NBrightBuyUtils.CheckRights()) strOut = AddProductGroupCategory(context);
                        break;
                    case "removeproductcategory":
                        if (NBrightBuyUtils.CheckRights()) strOut = RemoveProductCategory(context);
                        break;
                    case "removeproductgroupcategory":
                        if (NBrightBuyUtils.CheckRights()) strOut = RemoveProductGroupCategory(context);
                        break;
                    case "populatecategorylist":
                        if (NBrightBuyUtils.CheckRights()) strOut = GetGroupCategoryListBox(context);
                        break;
                    case "addrelatedproduct":
                        if (NBrightBuyUtils.CheckRights()) strOut = AddRelatedProduct(context);
                        break;
                    case "removerelatedproduct":
                        if (NBrightBuyUtils.CheckRights()) strOut = RemoveRelatedProduct(context);
                        break;
                    case "addproductclient":
                        if (NBrightBuyUtils.CheckRights()) strOut = AddProductClient(context);
                        break;
                    case "removeproductclient":
                        if (NBrightBuyUtils.CheckRights()) strOut = RemoveProductClient(context);
                        break;
                    case "clientdiscountcodes":
                        if (NBrightBuyUtils.CheckRights()) strOut = GetClientDiscountCodes(context);
                        break;
                    case "addclientdiscountcode":
                        if (NBrightBuyUtils.CheckRights()) strOut = AddClientDiscountCodes(context);
                        break;
                    case "clientvouchercodes":
                        if (NBrightBuyUtils.CheckRights()) strOut = GetClientVoucherCodes(context);
                        break;
                    case "addclientvouchercode":
                        if (NBrightBuyUtils.CheckRights()) strOut = AddClientVoucherCodes(context);
                        break;
                    case "moveproductadmin":
                        if (NBrightBuyUtils.CheckRights()) strOut = MoveProductAdmin(context);
                        break;
                    case "fileupload":
                        if (NBrightBuyUtils.CheckRights() && Utils.IsNumeric(itemId))
                        {
                            strOut = FileUpload(context);
                        }
                        break;
                    case "fileclientupload":
                        if (StoreSettings.Current.GetBool("allowupload"))
                        {
                            strOut = FileUpload(context, itemId);
                        }
                        break;
                    case "updateproductimages":
                        if (NBrightBuyUtils.CheckRights())
                        {
                            UpdateProductImages(context);
                            strOut = GetProductImages(context);
                        }
                        break;
                    case "updateproductdocs":
                        if (NBrightBuyUtils.CheckRights())
                        {
                            UpdateProductDocs(context);
                            strOut = GetProductDocs(context);
                        }
                        break;
                    case "addtobasket":
                        strOut = AddToBasket(context);
                        break;
                    case "addalltobasket":
                        strOut = AddAllToBasket(context);
                        break;
                    case "addcookietobasket":
                        break;
                    case "docdownload":
                        var fname = Utils.RequestQueryStringParam(context, "filename");
                        strOut = fname; // return this is error.
                        var downloadname = Utils.RequestQueryStringParam(context, "downloadname");
                        var fpath = HttpContext.Current.Server.MapPath(fname);
                        if (downloadname == "") downloadname = Path.GetFileName(fname);
                        Utils.ForceDocDownload(fpath, downloadname, context.Response);
                        break;
                    case "printproduct":
                        break;
                    case "removefromcart":
                        RemoveFromCart(context);
                        strOut = "removefromcart";
                        break;
                    case "recalculatecart":
                        RecalculateCart(context);
                        strOut = "recalculatecart";
                        break;
                    case "recalculatesummary":
                        RecalculateSummary(context);
                        strOut = "recalculatecart";
                        break;
                    case "redirecttopayment":
                        strOut = RedirectToPayment(context);
                        break;
                    case "updatebilladdress":
                        strOut = UpdateCartAddress(context, "bill");
                        break;
                    case "updateshipaddress":
                        strOut = UpdateCartAddress(context, "ship");
                        break;
                    case "updateshipoption":
                        strOut = UpdateCartAddress(context, "shipoption");
                        break;
                    case "rendercart":
                        strOut = RenderCart(context);
                        break;
                    case "renderpostdata":
                        strOut = RenderPostData(context);
                        break;
                    case "clearcart":
                        var currentcart = new CartData(PortalSettings.Current.PortalId);
                        currentcart.DeleteCart();
                        strOut = "clearcart";
                        break;
                    case "shippingprovidertemplate":
                        strOut = GetShippingProviderTemplates(context);
                        break;
                    case "getsettings":
                        strOut = GetSettings(context);
                        break;
                    case "savesettings":
                        if (NBrightBuyUtils.CheckRights()) strOut = SaveSettings(context);
                        break;
                    case "updateprofile":
                        strOut = UpdateProfile(context);
                        break;
                    case "dosearch":
                        strOut = DoSearch(context);
                        break;
                    case "resetsearch":
                        strOut = ResetSearch(context);
                        break;
                    case "orderby":
                        strOut = DoOrderBy(context);
                        break;
                    case "orderadmin_getlist":
                        strOut = OrderAdminList(context);
                        break;
                    case "orderadmin_getdetail":
                        strOut = OrderAdminDetail(context);
                        break;
                    case "orderadmin_reorder":
                        strOut = OrderAdminReOrder(context);
                        break;
                    case "orderadmin_edit":
                        strOut = OrderAdminEdit(context);
                        break;
                    case "orderadmin_save":
                        strOut = OrderAdminSave(context);
                        break;
                    case "orderadmin_removeinvoice":
                        strOut = OrderAdminRemoveInvoice(context);
                        break;
                    case "orderadmin_sendemail":
                        strOut = OrderAdminEmail(context);
                        break;
                }

                #endregion

            }
            catch (Exception ex)
            {
                strOut = ex.ToString();
                Exceptions.LogException(ex);
            }

            #region "return results"

            //send back xml as plain text
            context.Response.Clear();
            context.Response.ContentType = "text/plain";
            context.Response.Write(strOut);
            context.Response.End();

            #endregion
        }
Ejemplo n.º 11
0
        private string UpdateCartAddress(HttpContext context,String addresstype = "")
        {
            var currentcart = new CartData(PortalSettings.Current.PortalId);
                var ajaxInfo = GetAjaxInfo(context,true);

                currentcart.PurchaseInfo.SetXmlProperty("genxml/currentcartstage", "cartsummary"); // (Legacy) we need to set this so the cart calcs shipping

                if (addresstype == "bill")
                {
                    currentcart.AddBillingAddress(ajaxInfo);
                    currentcart.Save();
                }

                if (addresstype == "ship")
                {
                    if (currentcart.GetShippingOption() == "2") // need to test this, becuase in legacy code the shipping option is set to "2" when we save the shipping address.
                    {
                        currentcart.AddShippingAddress(ajaxInfo);
                        currentcart.Save();
                    }
                }

                if (addresstype == "shipoption")
                {
                    var shipoption = ajaxInfo.GetXmlProperty("genxml/radiobuttonlist/rblshippingoptions");
                    currentcart.SetShippingOption(shipoption);
                    currentcart.Save();
                }

                return addresstype;
        }
Ejemplo n.º 12
0
        private String RenderCart(HttpContext context)
        {
            var ajaxInfo = GetAjaxInfo(context);
            var carttemplate = ajaxInfo.GetXmlProperty("genxml/hidden/carttemplate");
            if (carttemplate == "") carttemplate = ajaxInfo.GetXmlProperty("genxml/hidden/minicarttemplate");
            var theme = ajaxInfo.GetXmlProperty("genxml/hidden/carttheme");
            if (theme == "") theme = ajaxInfo.GetXmlProperty("genxml/hidden/minicarttheme");
            var lang = ajaxInfo.GetXmlProperty("genxml/hidden/lang");
            var controlpath = ajaxInfo.GetXmlProperty("genxml/hidden/controlpath");
            if (controlpath == "") controlpath = "/DesktopModules/NBright/NBrightBuy";
            var razorTempl = "";
            if (carttemplate != "")
            {
                if (lang == "") lang = Utils.GetCurrentCulture();
                var currentcart = new CartData(PortalSettings.Current.PortalId);
                if (UserController.Instance.GetCurrentUserInfo().UserID != -1)  // If we have a user, do save to update userid, so addrees checkout can get addresses.
                {
                    if (currentcart.UserId != UserController.Instance.GetCurrentUserInfo().UserID && currentcart.EditMode == "")
                    {
                        currentcart.Save();
                    }
                }

                razorTempl = NBrightBuyUtils.RazorTemplRender(carttemplate, 0,"", currentcart, controlpath, theme, lang, StoreSettings.Current.Settings());
            }
            return razorTempl;
        }
Ejemplo n.º 13
0
 private string RemoveFromCart(HttpContext context)
 {
     var ajaxInfo = GetAjaxInfo(context);
         var currentcart = new CartData(PortalSettings.Current.PortalId);
         currentcart.RemoveItem(ajaxInfo.GetXmlProperty("genxml/hidden/itemcode"));
         currentcart.Save(StoreSettings.Current.DebugMode);
         return "OK";
 }
Ejemplo n.º 14
0
        private string RedirectToPayment(HttpContext context)
        {
            try
            {
                RecalculateSummary(context);

                var currentcart = new CartData(PortalSettings.Current.PortalId);

                if (currentcart.GetCartItemList().Count > 0)
                {
                    currentcart.SetValidated(true);
                    if (currentcart.EditMode == "E") currentcart.ConvertToOrder();
                }
                else
                {
                    currentcart.SetValidated(true);
                }
                currentcart.Save();

                var rtnurl = Globals.NavigateURL(StoreSettings.Current.PaymentTabId);
                if (currentcart.EditMode == "E")
                {
                    // is order being edited, so return to order status after edit.
                    // ONLY if the cartsummry is being displayed to the manager.
                    currentcart.ConvertToOrder();
                    // redirect to back office
                    var param = new string[2];
                    param[0] = "ctrl=orders";
                    param[1] = "eid=" + currentcart.PurchaseInfo.ItemID.ToString("");
                    var strbackofficeTabId = StoreSettings.Current.Get("backofficetabid");
                    var backofficeTabId = PortalSettings.Current.ActiveTab.TabID;
                    if (Utils.IsNumeric(strbackofficeTabId)) backofficeTabId = Convert.ToInt32(strbackofficeTabId);
                    rtnurl = Globals.NavigateURL(backofficeTabId, "", param);
                }
                return rtnurl;

            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return "ERROR";
            }
        }
Ejemplo n.º 15
0
        private string RecalculateSummary(HttpContext context)
        {
            var objCtrl = new NBrightBuyController();

            var currentcart = new CartData(PortalSettings.Current.PortalId);
                var ajaxInfo = GetAjaxInfo(context, true);
                var shipoption = currentcart.GetShippingOption(); // ship option already set in address update.

                currentcart.AddExtraInfo(ajaxInfo);
                currentcart.SetShippingOption(shipoption);
                currentcart.PurchaseInfo.SetXmlProperty("genxml/currentcartstage", "cartsummary"); // (Legacy) we need to set this so the cart calcs shipping
                currentcart.PurchaseInfo.SetXmlProperty("genxml/extrainfo/genxml/radiobuttonlist/shippingprovider", ajaxInfo.GetXmlProperty("genxml/radiobuttonlist/shippingprovider"));

            var shipref = ajaxInfo.GetXmlProperty("genxml/radiobuttonlist/shippingprovider");
            var displayanme = "";
            var shipInfo = objCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "SHIPPING", shipref);
            if (shipInfo != null)
            {
                displayanme = shipInfo.GetXmlProperty("genxml/textbox/shippingdisplayname");
            }
            if (displayanme == "") displayanme = shipref;
            currentcart.PurchaseInfo.SetXmlProperty("genxml/extrainfo/genxml/hidden/shippingdisplayanme", displayanme);

            var shippingproductcode = ajaxInfo.GetXmlProperty("genxml/hidden/shippingproductcode");
                currentcart.PurchaseInfo.SetXmlProperty("genxml/shippingproductcode", shippingproductcode);
                var pickuppointref = ajaxInfo.GetXmlProperty("genxml/hidden/pickuppointref");
                currentcart.PurchaseInfo.SetXmlProperty("genxml/pickuppointref", pickuppointref);
                var pickuppointaddr = ajaxInfo.GetXmlProperty("genxml/hidden/pickuppointaddr");
                currentcart.PurchaseInfo.SetXmlProperty("genxml/pickuppointaddr", pickuppointaddr);

                currentcart.Lang = ajaxInfo.Lang;  // set lang so we can send emails in same language the order was made in.

                currentcart.Save();

                return "OK";
        }
Ejemplo n.º 16
0
        private void ShippingProviderDataBind(object sender, EventArgs e)
        {
            var rbl = (RadioButtonList)sender;
            var container = (IDataItemContainer)rbl.NamingContainer;
            try
            {
                rbl.Visible = visibleStatus.DefaultIfEmpty(true).First();
                if (rbl.Visible)
                {
                    var strXML = Convert.ToString(DataBinder.Eval(container.DataItem, "XMLData"));
                    var nbInfo = new NBrightInfo();
                    nbInfo.XMLData = strXML;
                    var selectval = nbInfo.GetXmlProperty("genxml/radiobuttonlist/shippingprovider");

                    // get country code, to CheckBox if provider is valid.
                    var cartData = new CartData(PortalSettings.Current.PortalId);

                    var pluginData = new PluginData(PortalSettings.Current.PortalId);
                    var provList = pluginData.GetShippingProviders();
                        foreach (var d in provList)
                        {
                            var isValid = true;
                            var shipprov = ShippingInterface.Instance(d.Key);
                            if (shipprov != null) isValid = shipprov.IsValid(cartData.PurchaseInfo);
                            var p = d.Value;
                            if (isValid)
                            {
                                var li = new ListItem();
                                li.Text = p.GetXmlProperty("genxml/textbox/name");
                                li.Value = p.GetXmlProperty("genxml/textbox/ctrl");
                                if (li.Value == selectval) li.Selected = true;
                                rbl.Items.Add(li);
                            }
                        }
                        if (rbl.SelectedValue == "" && rbl.Items.Count > 0) rbl.SelectedIndex = 0;

                }

            }
            catch (Exception)
            {
                rbl.Visible = false;
            }
        }
Ejemplo n.º 17
0
        private void CartItemlistDataBind(object sender, EventArgs e)
        {
            var lc = (Literal)sender;
            var container = (IDataItemContainer)lc.NamingContainer;
            try
            {
                var strOut = "";
                lc.Visible = visibleStatus.DefaultIfEmpty(true).First();
                if (lc.Visible)
                {

                    var id = Convert.ToString(DataBinder.Eval(container.DataItem, "ItemId"));
                    var lang = Convert.ToString(DataBinder.Eval(container.DataItem, "lang"));
                    if (lang == "") lang = Utils.GetCurrentCulture();
                    var groupresults = false;
                    if (lc.Text.EndsWith(":GROUPBY"))
                    {
                        groupresults = true;
                        lc.Text = lc.Text.Replace(":GROUPBY", "");
                    }
                    var templName = lc.Text;
                    if (Utils.IsNumeric(id) && (templName != ""))
                    {
                        var buyCtrl = new NBrightBuyController();
                        var rpTempl = buyCtrl.GetTemplateData(-1, templName, lang, _settings, StoreSettings.Current.DebugMode);

                        //remove templName from template, so we don't get a loop.
                        if (rpTempl.Contains(templName)) rpTempl = rpTempl.Replace(templName, "");
                        //build models list

                        var objInfo = (NBrightInfo)container.DataItem;
                        var cartData = new CartData(objInfo.PortalId);
                        // render repeater
                        try
                        {
                            var itemTemplate = NBrightBuyUtils.GetGenXmlTemplate(rpTempl, _settings, PortalSettings.Current.HomeDirectory, visibleStatus);
                            strOut = GenXmlFunctions.RenderRepeater(cartData.GetCartItemList(groupresults), itemTemplate);
                        }
                        catch (Exception exc)
                        {
                            strOut = "ERROR: NOTE: sub rendered templates CANNOT contain postback controls.<br/>" + exc;
                        }
                    }
                }
                lc.Text = strOut;

            }
            catch (Exception)
            {
                lc.Text = "";
            }
        }
Ejemplo n.º 18
0
        public override NBrightInfo CalculatePromotion(int portalId, NBrightInfo cartInfo)
        {
            // loop through cart items
            var rtncartInfo = (NBrightInfo)cartInfo.Clone();
            try
            {

                var cartData = new CartData(cartInfo.PortalId);
                var cartList = cartData.GetCartItemList();

                foreach (var cartItemInfo in cartList)
                {
                    cartInfo.SetXmlPropertyDouble("genxml/items/genxml[./itemcode = '" + cartItemInfo.GetXmlProperty("genxml/itemcode") + "']/promodiscount", 0); // remove any existing discount
                    if (cartItemInfo.GetXmlProperty("genxml/productxml/genxml/hidden/promotype") == "PROMOMULTIBUY")
                    {

                        var promoid = cartItemInfo.GetXmlPropertyInt("genxml/productxml/genxml/hidden/promoid");
                        var objCtrl = new NBrightBuyController();
                        var promoData = objCtrl.GetData(promoid);
                        if (promoData != null)
                        {
                            //NOTE: WE nedd to process disabld promotions so they can be removed from cart

                            var buyqty = promoData.GetXmlPropertyInt("genxml/textbox/buyqty");
                            var validfrom = promoData.GetXmlProperty("genxml/textbox/validfrom");
                            var validuntil = promoData.GetXmlProperty("genxml/textbox/validuntil");
                            var propbuygroupid = promoData.GetXmlProperty("genxml/dropdownlist/propbuy");
                            var propapplygroupid = promoData.GetXmlProperty("genxml/dropdownlist/propapply");
                            var amounttype = promoData.GetXmlProperty("genxml/radiobuttonlist/amounttype");
                            var amount = promoData.GetXmlPropertyDouble("genxml/textbox/amount");

                                // Applied discount to this single cart item
                            if (!promoData.GetXmlPropertyBool("genxml/checkbox/disabled") && cartItemInfo.GetXmlPropertyInt("genxml/qty") >= buyqty && Utils.IsDate(validfrom) && Utils.IsDate(validuntil)) // check we have correct qty to activate promo
                            {
                                var dteF = Convert.ToDateTime(validfrom).Date;
                                var dteU = Convert.ToDateTime(validuntil).Date;
                                if (DateTime.Now.Date >= dteF && DateTime.Now.Date <= dteU)
                                {
                                    // calc discount amount

                                    var cartqty = cartItemInfo.GetXmlPropertyDouble("genxml/qty");
                                    var qtycount = cartqty;
                                    var unitcost = cartItemInfo.GetXmlPropertyDouble("genxml/basecost");
                                    double discountamt = 0;
                                    while (qtycount > buyqty)
                                    {
                                        if (amounttype == "1")
                                        {
                                            discountamt += (unitcost - amount);
                                        }
                                        else
                                        {
                                            discountamt += ((unitcost/100)*amount);
                                        }
                                        if (discountamt < 0) discountamt = 0;

                                        qtycount = (qtycount - (buyqty + 1)); // +1 so we allow for discount 1 in basket.
                                    }

                                    cartInfo.SetXmlPropertyDouble("genxml/items/genxml[./itemcode = '" + cartItemInfo.GetXmlProperty("genxml/itemcode") + "']/promodiscount", discountamt);

                                }
                            }
                        }
                    }
                }

                return cartInfo;
            }
            catch (Exception ex)
            {
                var x = ex.ToString();
                return rtncartInfo;
            }
        }
Ejemplo n.º 19
0
        protected void CtrlItemCommand(object source, RepeaterCommandEventArgs e)
        {
            var cArg = e.CommandArgument.ToString();
            var param = new string[3];
            var navigationData = new NavigationData(PortalId, "ClientsAdmin");

            switch (e.CommandName.ToLower())
            {
                case "entrydetail":
                    param[0] = "uid=" + cArg;
                    if (_page != "") param[1] = "page=" + _page;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "return":
                    param[0] = "";
                    if (_page != "") param[1] = "page=" + _page;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "search":
                    navigationData.XmlData = GenXmlFunctions.GetGenXml(rpSearch,"","");
                    navigationData.Save();
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "resetsearch":
                    // clear cookie info
                    navigationData.Delete();
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "unlockuser":
                    if (Utils.IsNumeric(cArg))
                    {
                        var clientData = new ClientData(PortalId, Convert.ToInt32(cArg));
                        clientData.UnlockUser();
                    }
                    param[0] = "uid=" + cArg;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "deleteuser":
                    if (Utils.IsNumeric(cArg))
                    {
                        var clientData = new ClientData(PortalId, Convert.ToInt32(cArg));
                        clientData.DeleteUser();
                    }
                    param[0] = "uid=" + cArg;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "removeuser":
                    if (Utils.IsNumeric(cArg))
                    {
                        var clientData = new ClientData(PortalId, Convert.ToInt32(cArg));
                        var ok = clientData.RemoveUser();
                        if (!ok)
                        {
                            NBrightBuyUtils.SetNotfiyMessage(ModuleId,"removeuser", NotifyCode.fail);
                            param[0] = "uid=" + cArg;
                        }
                    }
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "validateuser":
                    if (Utils.IsNumeric(cArg))
                    {
                        var clientData = new ClientData(PortalId, Convert.ToInt32(cArg));
                        clientData.AuthoriseClient();
                        clientData.AddClientRole(ModSettings);
                        if (StoreSettings.Current.Get("resetpasswordonclientvalidate") == "True") clientData.ResetPassword();
                    }
                    param[0] = "uid=" + cArg;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "resetpass":
                    if (Utils.IsNumeric(cArg))
                    {
                        var clientData = new ClientData(PortalId, Convert.ToInt32(cArg));
                        clientData.ResetPassword();
                    }
                    param[0] = "uid=" + cArg;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "viewaddressbook":
                    param[0] = "";
                    if (Utils.IsNumeric(cArg))
                    {
                        param[0] = "ctrl=addressbook";
                        param[1] = "uid=" + cArg;
                    }
                    Response.Redirect(Globals.NavigateURL(TabId, "", param), true);
                    break;
                case "vieworders":
                    param[0] = "";
                    if (Utils.IsNumeric(cArg))
                    {
                        param[0] = "ctrl=orders";
                        param[1] = "uid=" + cArg;
                    }
                    Response.Redirect(Globals.NavigateURL(TabId, "", param), true);
                    break;
                case "createorder":
                    param[0] = "";
                    var tabId = TabId;
                    if (Utils.IsNumeric(cArg))
                    {
                        var cart = new CartData(PortalId);
                        cart.UserId = Convert.ToInt32(cArg);
                        cart.EditMode = "C";
                        cart.Save();
                        tabId = StoreSettings.Current.GetInt("productlisttab");
                        if (tabId==0) tabId = TabId;
                    }
                    Response.Redirect(NBrightBuyUtils.AdminUrl(tabId, param), true);
                    break;
                case "save":
                    if (Utils.IsNumeric(cArg))
                    {
                        var clientData = new ClientData(PortalId, Convert.ToInt32(cArg));
                        if (clientData.Exists)
                        {
                            clientData.Update(rpData);
                            clientData.Save();
                        }
                    }
                    param[0] = "uid=" + cArg;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
            }
        }
Ejemplo n.º 20
0
 public static string RenderCart(string theme, string carttemplate, string controlPath = "/DesktopModules/NBright/NBrightBuy")
 {
     var razorTempl = "";
     if (carttemplate != "")
     {
         var currentcart = new CartData(PortalSettings.Current.PortalId);
         razorTempl = NBrightBuyUtils.RazorTemplRender(carttemplate, 0, "", currentcart, controlPath, theme, Utils.GetCurrentCulture(), StoreSettings.Current.Settings());
     }
     return razorTempl;
 }
Ejemplo n.º 21
0
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            if (ModSettings.Get("themefolder") == "")  // if we don't have module setting jump out
            {
                rpPaymentGateways.ItemTemplate = new GenXmlTemplate("NO MODULE SETTINGS");
                return;
            }

            try
            {

                var pluginData = new PluginData(PortalSettings.Current.PortalId);
                _provList = pluginData.GetPaymentProviders();
                _cartInfo = new CartData(PortalId);

                var orderid = Utils.RequestQueryStringParam(Context, "orderid");
                var templOk = ModSettings.Get("paymentoktemplate");
                var templFail = ModSettings.Get("paymentfailtemplate");
                var templHeader = "";
                var templFooter = "";
                var templText = "";

                if ((_provList.Count == 0 || _cartInfo.PurchaseInfo.GetXmlPropertyDouble("genxml/appliedtotal") <= 0) && orderid == "")
                {
                    #region "No Payment providers, so process as a ordering system"

                    var displayTempl = templOk;
                    if (!_cartInfo.IsValidated()) displayTempl = templFail;

                    rpDetailDisplay.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(ModCtrl.GetTemplateData(ModSettings, displayTempl, Utils.GetCurrentCulture(), DebugMode), ModSettings.Settings(), PortalSettings.HomeDirectory);
                    _templateHeader = (GenXmlTemplate) rpDetailDisplay.ItemTemplate;

                    #endregion
                }
                else
                {
                    #region "Payment Details"

                    // display the payment method by default
                    templHeader = ModSettings.Get("paymentordersummary");
                    templFooter = ModSettings.Get("paymentfooter");
                    var templPaymentText = "";
                    var msg = "";
                    if (Utils.IsNumeric(orderid))
                    {
                        // orderid exists, so must be return from bank; Process it!!
                        _orderData = new OrderData(PortalId, Convert.ToInt32(orderid));
                        _prov = PaymentsInterface.Instance(_orderData.PaymentProviderKey);

                        msg = _prov.ProcessPaymentReturn(Context);
                        if (msg == "") // no message so successful
                        {
                            _orderData = new OrderData(PortalId, Convert.ToInt32(orderid)); // get the updated order.
                            _orderData.PaymentOk("050");
                            templText = templOk;
                        }
                        else
                        {
                            _orderData = new OrderData(PortalId, Convert.ToInt32(orderid)); // reload the order, becuase the status and typecode may have changed by the payment provider.
                            _orderData.AddAuditMessage(msg, "paymsg", "payment.ascx", "False");
                            _orderData.Save();
                            templText = templFail;
                        }
                        templFooter = ""; // return from bank, hide footer
                    }
                    else
                    {
                        // not returning from bank, so display list of payment providers.
                        rpPaymentGateways.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(GetPaymentProviderTemplates(), ModSettings.Settings(), PortalSettings.HomeDirectory);
                    }

                    if (templText == "") templText = templHeader; // if we are NOT returning from bank, then display normal header summary template
                    templPaymentText = ModCtrl.GetTemplateData(ModSettings, templText, Utils.GetCurrentCulture(), DebugMode);

                    rpDetailDisplay.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(templPaymentText, ModSettings.Settings(), PortalSettings.HomeDirectory);
                    _templateHeader = (GenXmlTemplate) rpDetailDisplay.ItemTemplate;

                    if (templFooter != "")
                    {
                        var templPaymentFooterText = ModCtrl.GetTemplateData(ModSettings, templFooter, Utils.GetCurrentCulture(), DebugMode);
                        rpDetailFooter.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(templPaymentFooterText, ModSettings.Settings(), PortalSettings.HomeDirectory);
                    }

                    #endregion
                }

                // insert page header text
                NBrightBuyUtils.IncludePageHeaders(ModCtrl, ModuleId, Page, _templateHeader, ModSettings.Settings(), null, DebugMode);

            }
            catch (Exception exc)
            {
                //display the error on the template (don;t want to log it here, prefer to deal with errors directly.)
                var l = new Literal();
                l.Text = exc.ToString();
                phData.Controls.Add(l);
            }
        }
Ejemplo n.º 22
0
        private String GetShippingProviderTemplates(HttpContext context)
        {
            var ajaxInfo = GetAjaxInfo(context);
            var activeprovider = ajaxInfo.GetXmlProperty("genxml/hidden/shippingprovider");
            var currentcart = new CartData(PortalSettings.Current.PortalId);

            var shipoption = currentcart.GetShippingOption(); // we don't want to overwrite the selected shipping option.
            currentcart.AddExtraInfo(ajaxInfo);
            currentcart.SetShippingOption(shipoption);
            currentcart.PurchaseInfo.SetXmlProperty("genxml/currentcartstage", "cartsummary"); // (Legacy) we need to set this so the cart calcs shipping
            currentcart.Save();

            if (activeprovider == "") activeprovider = currentcart.PurchaseInfo.GetXmlProperty("genxml/extrainfo/genxml/radiobuttonlist/shippingprovider");

            var strRtn = "";
            var pluginData = new PluginData(PortalSettings.Current.PortalId);
            var provList = pluginData.GetShippingProviders();
            if (provList != null && provList.Count > 0)
            {
                if (activeprovider == "") activeprovider = provList.First().Key;
                foreach (var d in provList)
                {
                    var p = d.Value;
                    var shippingkey = p.GetXmlProperty("genxml/textbox/ctrl");
                    var shipprov = ShippingInterface.Instance(shippingkey);
                    if (shipprov != null)
                    {
                        if (activeprovider == d.Key)
                        {
                            var razorTempl = shipprov.GetTemplate(currentcart.PurchaseInfo);
                            var objList = new List<NBrightInfo>();
                            objList.Add(currentcart.PurchaseInfo);
                            if (razorTempl.StartsWith("@"))
                            {
                                strRtn += NBrightBuyUtils.RazorRender(objList, razorTempl, shippingkey + "shippingtemplate", StoreSettings.Current.DebugMode);
                            }
                            else
                            {
                                strRtn += GenXmlFunctions.RenderRepeater(objList[0], razorTempl, "", "XMLData", "", StoreSettings.Current.Settings(), null);
                            }
                        }
                    }
                }
            }
            return strRtn;
        }