/// <summary> /// Initializes a new instance of the <see cref="Shipment"/> class. /// </summary> /// <param name="_address">The _address.</param> /// <param name="_order">The _order.</param> /// <param name="_id">The _id.</param> /// <param name="_shipmentNumber">The _shipment number.</param> /// <param name="_tracking">The _tracking.</param> /// <param name="_dateShipped">The _date shipped.</param> /// <param name="_actualWeight">The _actual weight.</param> /// <param name="_actualService">The _actual service.</param> /// <param name="_actualCost">The _actual cost.</param> /// <param name="_actualBilledWeight">The _actual billed weight.</param> /// <param name="_packageLength">Length of the _package.</param> /// <param name="_packageWidth">Width of the _package.</param> /// <param name="_packageHeight">Height of the _package.</param> /// <param name="_thirdPartyAccount">The _third party account.</param> /// <param name="_voidStatus">The _void status.</param> /// <param name="_emailSent">The _email sent.</param> /// <param name="_addDate">The _add date.</param> public Shipment(Commerce.Address _address, Commerce.Order _order, Guid _id, string _shipmentNumber, string _tracking, string _dateShipped, string _actualWeight, string _actualService, string _actualCost, string _actualBilledWeight, string _packageLength, string _packageWidth, string _packageHeight, string _thirdPartyAccount, string _voidStatus, DateTime _emailSent, DateTime _addDate) { Address = _address; Order = _order; Id = _id; ShipmentNumber = _shipmentNumber; Tracking = _tracking; DateShipped = _dateShipped; ActualWeight = _actualWeight; ActualService = _actualService; ActualCost = _actualCost; ActualBilledWeight = _actualBilledWeight; PackageLength = _packageLength; PackageWidth = _packageWidth; PackageHeight = _packageHeight; ThirdPartyAccount = _thirdPartyAccount; VoidStatus = _voidStatus; EmailSent = _emailSent; AddDate = _addDate; }
public string main(Session session,Commerce.Item item,Commerce.CartItem cartItem,object current) { StringBuilder b=new StringBuilder(""); decimal basePrice; if(item.IsOnSale) { basePrice=item.SalePrice; } else { basePrice=item.Price; } if(session!=null) { if(session.User!=null) { if(session.User.WholesaleDealer) { basePrice=item.WholeSalePrice; } } } b.Append("<script language=\"javascript\" type=\"text/javascript\">"+@" window._p = function(){ updateSelectablePrice("+basePrice+@",document.getElementById('prices'),document.getElementById('price')); } $(function(){ setTimeout(function(){ window._p(); },1000); }) function updateSelectablePrice(_basePrice, inputContainerSelector, priceElementSelector, callbackProcedure) { var formElements = $(inputContainerSelector).find(':input'); var priceElement = $(priceElementSelector); var total = 0; /* for newbies to JS: when adding floats - money - it's important to _first_ convert all numbers to integers then covert them back to floats (x*100 / 100).toFixed(2) */ for (var x = 0; formElements.length > x; x++) { var i = formElements[x]; /* form constructor.cs select options contain attributes called 'price' and 'itemNumber' */ if (i.tagName.toLowerCase() == 'select') { /* get the selected option */ var opt = i.options[i.selectedIndex]; var price = 0; var itemNumber = ''; var _price = opt.getAttribute('price'); var _itemNumber = opt.getAttribute('itemNumber'); if (_price != undefined) { if (!isNaN(parseFloat(_price))) { price = parseInt(parseFloat(_price) * 100); total += price; } } if (_itemNumber != undefined) { itemNumber = _itemNumber; } if (i.previousSibling) { if (i.previousSibling.className=='info') { var info = i.previousSibling; info.onmouseover = function (e) { /* put info bubble */ } info.onclick = function (e) { /* put info bubble */ } } } } } var basePrice = parseInt(parseFloat(_basePrice) * 100); total += basePrice; if (priceElement[0]) { priceElement[0].innerHTML = '$' + (parseFloat(total) / parseFloat(100)).toFixed(2); } if (callbackProcedure) { callbackProcedure.apply(this, []); } } </script>"); try { string thisPropertyName=""; List<string> selects=new List<string>(); /* make the selects list */ item.Properties.Sort(delegate(Commerce.Property p1, Commerce.Property p2){ return p1.Name.CompareTo(p2.Name); }); foreach(Commerce.Property p in item.Properties) { bool endSelect=false; if(thisPropertyName!=p.Name) { thisPropertyName=p.Name; selects.Add(thisPropertyName); } } item.Properties.Sort(delegate(Commerce.Property p1, Commerce.Property p2){ return p1.Order.CompareTo(p2.Order); }); b.Append("<div class=\"prodcutDetailControls\" style=\"margin:10px;width:auto;\" id=\"prices\">"); foreach(string select in selects) { b.Append(select+"<br>"); b.Append("<select style=\"width:100%;\" name=\""+select+"\" onchange=\"_p();\">"); foreach(Commerce.Property p in item.Properties) { if(select==p.Name) { string price="0.00"; Commerce.Item i=Rendition.Commerce.Item.GetItem(p.Value); if(i!=null) { if(i.IsOnSale) { price=i.SalePrice.ToString("f"); } else { price=i.Price.ToString("f"); } if(session!=null) { if(session.User!=null) { if(session.User.WholesaleDealer) { price=i.WholeSalePrice.ToString("f"); } } } } if(price=="0.00") { b.Append("<option itemNumber=\""+p.Value+"\" price=\"0\" value=\""+p.Value+"\">"+p.Text+"</option>"); } else { b.Append("<option itemNumber=\""+p.Value+"\" price=\""+price.ToString()+"\" value=\""+p.Value+"\">"+p.Text+" +$"+price+"</option>"); } } } b.Append("</select><br>"); } b.Append("</div>"); return b.ToString(); } catch(Exception e) { return e.Message; } }
/// <summary> /// Emails A friend information about this item using the createemail event handler. /// </summary> /// <param name="item">The item.</param> /// <param name="user">The user.</param> /// <param name="message">The message.</param> /// <param name="emailTo">Send the email to.</param> /// <returns>{error:0,desc:"error description"}.</returns> public static Dictionary<string, object> EmailAFriend(Commerce.Item item, Commerce.User user, string message, string emailTo) { CreateEmailEventArgs emailArgs = new CreateEmailEventArgs("emailAFriend", Main.Site.site_operator_email, user.Email, Main.Site.site_log_email, user, Main.GetCurrentSession(), null, item, message, null); DefaultEmails.EmailAFriend(ref emailArgs); Main.Site.raiseOnCreateEmail(emailArgs); using(SqlConnection cn = Site.CreateConnection(true, true)) { cn.Open(); return Commerce.SendEmailArgResult(emailArgs, cn, null); } }
/// <summary> /// Gets most of the order's by info using various methods. Formated for JSON. /// </summary> /// <param name="orderNumber">The order number. Pass null if not used.</param> /// <param name="orderId">The order id. Pass a value less than 0 if not use.)</param> /// <param name="order">The order. If you already have an order object loaded you can pass it preventing addtional database queries.</param> /// <param name="cn">The sql connection.</param> /// <param name="trans">The transaction.</param> /// <returns></returns> public static Dictionary<string, object> GetOrderJson(string orderNumber, int orderId, Commerce.Order order, SqlConnection cn, SqlTransaction trans) { Dictionary<string, object> j = new Dictionary<string, object>(); cn = (SqlConnection)Utilities.Iif(cn == null, Site.SqlConnection, cn); if(order == null) { if(orderNumber != null) { order = Commerce.Order.GetOrderByOrderNumber(orderNumber, cn, trans); } else if(orderId > -1) { order = Commerce.Order.GetOrderByOrderId(orderId, cn, trans); } } if(order == null) { j.Add("error", -1); j.Add("description", String.Format("Order {0} not found.", orderNumber)); return j; } j.Add("error", 0); j.Add("description", ""); j.Add("approvedBy", order.ApprovedBy); j.Add("billToAddress", order.BillToAddress); j.Add("canceled", order.Canceled); j.Add("closed", order.Closed); j.Add("comment", order.Comment); j.Add("deliverBy", order.DeliverBy); j.Add("discount", order.Discount); j.Add("FOB", order.FOB); j.Add("grandTotal", order.GrandTotal); j.Add("manifest", order.Manifest); j.Add("orderDate", order.OrderDate); j.Add("orderId", order.OrderId); j.Add("orderNumber", order.OrderNumber); j.Add("paid", order.Paid); j.Add("parentOrderId", order.ParentOrderId); j.Add("paymentMethodId", order.PaymentMethodId); j.Add("purchaseOrder", order.PurchaseOrder); j.Add("readyForExport", order.ReadyForExport); j.Add("recalculatedOn", order.RecalculatedOn); j.Add("requisitionedBy", order.RequisitionedBy); j.Add("scanned_order_image", order.ScannedOrderImage); j.Add("service1", order.Service1); j.Add("service2", order.Service2); j.Add("sessionId", order.SessionId); j.Add("shippingTotal", order.ShippingTotal); j.Add("shipToAddress", order.ShipToAddress); j.Add("soldBy", order.SoldBy); j.Add("subTotal", order.SubTotal); j.Add("taxTotal", order.TaxTotal); j.Add("term", order.Term); j.Add("user", order.User); j.Add("userId", order.UserId); j.Add("vendor_accountNo", order.VendorAccountNumber); j.Add("lastStatusId", order.LastStatusId); j.Add("lastStatus", order.LastStatus); List<Dictionary<string, object>> lines = new List<Dictionary<string, object>>(); foreach(Commerce.Line line in order.Lines) { Dictionary<string, object> l = new Dictionary<string, object>(); l.Add("addressId", line.AddressId); l.Add("addTime", line.AddTime); l.Add("backorderedQty", line.BackorderedQty); l.Add("canceledQty", line.CanceledQty); l.Add("cartId", line.CartId); l.Add("customLineNumber", line.CustomLineNumber); l.Add("epsmmcsAIFilename", line.EPSMMCSAIFileName); l.Add("epsmmcsOutput", line.EPSMMCSOutput); l.Add("estimatedFulfillmentDate", line.EstimatedFulfillmentDate); l.Add("fulfillmentDate", line.FulfillmentDate); l.Add("itemNumber", line.ItemNumber); l.Add("kitAllocationCartId", line.KitAllocationCartId); l.Add("kitAllocationId", line.KitAllocationId); l.Add("kitQty", line.KitQty); l.Add("lineDetail", line.LineDetail); l.Add("lineNumber", line.LineNumber); l.Add("noTaxValueCostTotal", line.NoTaxValueCostTotal); l.Add("orderId", line.OrderId); l.Add("orderNumber", line.OrderNumber); l.Add("parentCartId", line.ParentCartId); l.Add("price", line.Price); l.Add("qty", line.Qty); l.Add("serialId", line.SerialId); l.Add("serialNumber", line.SerialNumber); l.Add("shipmentId", line.ShipmentId); l.Add("shipmentNumber", line.ShipmentNumber); l.Add("showAsSeperateLineOnInvoice", line.ShowAsSeperateLineOnInvoice); l.Add("valueCostTotal", line.ValueCostTotal); l.Add("vendorItemKitAssignmentId", line.VendorItemKitAssignmentId); l.Add("lastStatus", line.LastStatus); l.Add("lastStatusId", line.LastStatusId); Dictionary<string, object> form = new Dictionary<string, object>(); form.Add("HTML", line.Form.HtmlWithValues()); form.Add("name", line.Form.Name); form.Add("inputs", line.Form.Inputs); form.Add("ext", line.Form.Extention); l.Add("form", form); l.Add("item", Admin.GetItem(line.ItemNumber)); lines.Add(l); } j.Add("lines", lines); return j; }
/// <summary> /// Gets most of the order's info by reading an existing order object. Formated for JSON. /// </summary> /// <param name="order">The order.</param> /// <returns></returns> public static Dictionary<string, object> GetOrderJson(Commerce.Order order) { return GetOrderJson(null, -1, order, null, null); }
/// <summary> /// Emails the user a shipment update containing all the information about their shipment. /// </summary> /// <param name="order">The order.</param> /// <param name="args">Dictionary containing the shipmentId.</param> /// <returns>{error:0,desc:"error description"}.</returns> public static Dictionary<string, object> ShipmentUpdateEmail(Commerce.Order order, ShipmentUpdateArgs args) { CreateEmailEventArgs emailArgs = new CreateEmailEventArgs("shipmentUpdate", Main.Site.site_operator_email, order.User.Email, Main.Site.site_log_email, order.User, null, order, null, "", args); DefaultEmails.ShipConfirm(ref emailArgs); Main.Site.raiseOnCreateEmail(emailArgs); Dictionary<string, object> f; using(SqlConnection cn = Site.CreateConnection(true, true)) { cn.Open(); f = SendEmailArgResult(emailArgs, cn, null); } return f; }
/// <summary> /// Emails information about this order using the createemail event handler. /// </summary> /// <param name="order">The order.</param> /// <param name="cn">The cn.</param> /// <param name="trans">The trans.</param> /// <returns> /// {error:0,desc:"error description"}. /// </returns> public static Dictionary<string, object> PlacedOrderEmail(Commerce.Order order, SqlConnection cn, SqlTransaction trans) { User user = Main.Site.Users.List.Find(delegate(Commerce.User u) { return u.UserId == order.UserId; }); CreateEmailEventArgs emailArgs = new CreateEmailEventArgs("orderConfirm", Main.Site.site_operator_email, user.Email, Main.Site.site_log_email, user, Main.GetCurrentSession(), order, null, "", null); DefaultEmails.OrderConfirm(ref emailArgs); Main.Site.raiseOnCreateEmail(emailArgs); return SendEmailArgResult(emailArgs, cn, trans); }
/// <summary> /// Gets the review stars. /// </summary> /// <param name="i">The i.</param> /// <param name="displayMode">0: display just the stars, 1: Display with the text description.</param> /// <returns></returns> public static string GetReviewStars(Commerce.Item i, int displayMode) { StringBuilder b = new StringBuilder(); double avgRating = 0; if(i.Reviews.Count > 0) { for(int j = 0; i.Reviews.Count > j; j++) { /* it's important to add 1 to the zero based * review system or we'll end up with a * devide by zero error. Or Even better! * for some reason C# will produce an * Infinity so the error will be really * difficult to track down. */ avgRating += (i.Reviews[j].Rating + 1); } avgRating = Math.Round(avgRating / i.Reviews.Count, 3); } double star = Math.Round(avgRating * (1 / 0.25), 0) / (1 / 0.25); string startSuffx = ""; if(star > 0 && star.ToString("#####.##").Contains(".")) { startSuffx = "0." + star.ToString("#####.##").Split('.')[1]; } for(int j = 0; Math.Floor(avgRating) > j; j++) { b.Append("<img src=\"/img/star.png\" title=\"" + avgRating.ToString() + " of 5 Stars\" " + " alt=\"" + avgRating.ToString() + " of 5 Stars\">"); } if(startSuffx.Length > 0) { b.Append("<img src=\"/img/star" + startSuffx + ".png\" title=\"" + avgRating.ToString() + " of 5 Stars\" " + " alt=\"" + avgRating + "\" of 5 Stars\">"); } if(displayMode != 0 && i.Reviews.Count > 0) { b.Append("<span>" + avgRating.ToString() + " of 5 (" + i.Reviews.Count.ToString() + ")</span>"); } return b.ToString(); }
/// <summary> /// Initializes a new instance of the <see cref="Form"/> class. /// </summary> /// <param name="item">The item.</param> /// <param name="formSourceCode">The form source code.</param> /// <param name="formName">Name of the form.</param> public Form( Commerce.Item item, string formSourceCode, string formName ) { this.Item = item; Name = ""; Path = ""; if( formName == null ) { this.Extention = ""; this._sourceCode = ""; this._inputs = new List<Input>(); } else { this.Extention = System.IO.Path.GetExtension(formName).ToLower(); this._sourceCode = formSourceCode; try { this._inputs = GetFormInputs( RenderForm( this._sourceCode ) ); } catch( Exception ex ) { String.Format( "Commerce.form > renderForm exception > {0}", ex.Message ).Debug( 0 ); } if( this._inputs == null ) { this._inputs = new List<Input>(); } } }
/// <summary> /// Initializes a new instance of the <see cref="Form"/> class. /// </summary> /// <param name="item">The item.</param> public Form( Commerce.Item item ) { FormErrors = new List<object>(); this.Item = item; Path = ""; Extention = ""; Name = "NO FORM"; _sourceCode = ""; _renderedForm = ""; }
/// <summary> /// Initializes a new instance of the <see cref="Form"/> class. /// </summary> /// <param name="item">The item.</param> /// <param name="path">The path.</param> public Form( Commerce.Item item, string path ) { FormErrors = new List<object>(); this.Item = item; this.Path = System.IO.Path.GetFullPath( path ); this.Name = System.IO.Path.GetFileName(path); this.Extention = System.IO.Path.GetExtension(path).ToLower(); this._sourceCode = IncludeFile( path ); try { this._inputs = GetFormInputs( RenderForm( this._sourceCode ) ); } catch( Exception ex ) { String.Format( "Commerce.form > renderForm exception > {0}", ex.Message ).Debug( 0 ); } if( this._inputs == null ) { this._inputs = new List<Input>(); } }
/// <summary> /// Internal method used by CreateMenuHierarchy to create HTML menus. /// </summary> /// <param name="menu">The menu.</param> /// <param name="childCode">The child code.</param> /// <param name="rootCode">The root code.</param> /// <param name="rewriteFilter">Rewrite Match Pattern.</param> /// <param name="rewriteReplace">Rewrite Replace.</param> /// <param name="recursive">if set to <c>true</c> child menus will be rendered.</param> /// <returns> /// built string /// </returns> private string BuildMenu( Commerce.Menu menu, MenuCollectionCode childCode, MenuCollectionCode rootCode, string rewriteFilter, string rewriteReplace, bool recursive = true ) { /* empty root menus should return nothing */ if(menu.Id==Guid.Empty){return "";}; StringBuilder sb = new StringBuilder(); MenuCollectionCode s = childCode; if( rootCode != null ) { s = rootCode; } string id = Guid.NewGuid().ToBase64DomId(); sb.Append( s.MenuItem[ 0 ] ); sb.Append( " id=\"" + id + "\" " ); sb.Append( s.MenuItemClassName ); sb.Append( s.MenuItemMouseOver ); sb.Append( s.MenuItemMouseOut ); sb.Append( s.MenuItemClick ); sb.Append( s.MenuItemMouseDown ); sb.Append( s.MenuItemMouseUp ); sb.Append( s.MenuItem[ 1 ] ); sb.Append( s.MenuLink[ 0 ] ); sb.Append( " href=\"" + menu.Href + "\" " ); sb.Append( s.MenuLink[ 1 ] ); sb.Append( menu.Name ); sb.Append( s.MenuLink[ 2 ] ); if( menu.Menus.Count > 0 ) { id = Guid.NewGuid().ToBase64DomId(); sb.Append( childCode.Menu[ 0 ] ); sb.Append( " id=\"" + id + "\" " ); sb.Append( childCode.MenuClassName ); sb.Append( childCode.MenuMouseOver ); sb.Append( childCode.MenuMouseOut ); sb.Append( childCode.MenuClick ); sb.Append( childCode.MenuMouseDown ); sb.Append( childCode.MenuMouseUp ); sb.Append( childCode.Menu[ 1 ] ); foreach( Commerce.Menu m in menu.Menus ) { sb.Append( BuildMenu( m, childCode, null, rewriteFilter, rewriteReplace ) ); } sb.Append( childCode.Menu[ 2 ] ); } sb.Append( s.MenuItem[ 2 ] ); if( rewriteFilter.Length > 0 ) { return Regex.Replace( sb.ToString(), rewriteFilter, rewriteReplace ); } else { return sb.ToString(); } }
/// <summary> /// Initializes a new instance of the <see cref="ConversationMessage"/> class. /// </summary> /// <param name="_message">The _message.</param> /// <param name="_user">The _user.</param> public ConversationMessage( string _message, Commerce.User _user ) { Message = _message; User = _user; }
/// <summary> /// Removes the user. /// </summary> /// <param name="user">The user.</param> public void RemoveUser( Commerce.User user ) { /* don't add the same user twice */ if(!Users.Contains( user ) ) { return; }; Users.Remove( user ); UserIds.Remove( user.UserId ); Version++; return; }
/// <summary> /// Adds a user to the Conversation. /// </summary> /// <param name="user">The user.</param> public void AddUser(Commerce.User user) { /* don't add the same user twice */ if(Users.Contains(user)){return;}; Users.Add(user); UserIds.Add(user.UserId); Version++; return; }