@model DiscountModel @using SmartStore.Core.Domain.Discounts; @using Telerik.Web.Mvc.UI; @using SmartStore.Web.Framework.UI; @{ Html.AddScriptParts(true, "~/Administration/Scripts/jquery.tmpl.min.js"); Html.AddScriptParts(true, "~/Administration/Scripts/smartstore.discountrules.js"); } @Html.ValidationSummary(false) @Html.HiddenFor(model => model.Id) @Html.SmartStore().TabStrip().Name("discount-edit").Items(x => { x.Add().Text(T("Admin.Promotions.Discounts.Info").Text).Content(TabInfo()).Selected(true); x.Add().Text(T("Admin.Promotions.Discounts.Requirements").Text).Content(TabRequirements()); if (Model.Id > 0) { x.Add().Text(T("Admin.Promotions.Discounts.History").Text).Content(TabHistory()); } //generate an event EngineContext.Current.Resolve().Publish(new TabStripCreated(x, "discount-edit", this.Html, this.Model)); }) @helper TabInfo() {
@Html.SmartLabelFor(model => model.Name) @Html.EditorFor(model => model.Name) @Html.ValidationMessageFor(model => model.Name)
@Html.SmartLabelFor(model => model.DiscountTypeId) @Html.DropDownListFor(model => model.DiscountTypeId, ((DiscountType)Model.DiscountTypeId).ToSelectList()) @Html.ValidationMessageFor(model => model.DiscountTypeId)
@Html.SmartLabelFor(model => model.AppliedToCategoryModels) @if (Model.AppliedToCategoryModels.Count > 0) { for (int i = 0; i < Model.AppliedToCategoryModels.Count; i++) { var categoryId = Model.AppliedToCategoryModels[i].CategoryId; var categoryName = Model.AppliedToCategoryModels[i].Name; @categoryName if (i != Model.AppliedToCategoryModels.Count - 1) { , } } } else { @T("Admin.Promotions.Discounts.Fields.AppliedToCategories.NoRecords") }
@Html.SmartLabelFor(model => model.AppliedToProductModels) @if (Model.AppliedToProductModels.Count > 0) { for (int i = 0; i < Model.AppliedToProductModels.Count; i++) { var productId = Model.AppliedToProductModels[i].ProductId; var productName = Model.AppliedToProductModels[i].ProductName; @productName if (i != Model.AppliedToProductModels.Count - 1) { , } } } else { @T("Admin.Promotions.Discounts.Fields.AppliedToProducts.NoRecords") }
@Html.SmartLabelFor(model => model.UsePercentage) @Html.EditorFor(model => model.UsePercentage) @Html.ValidationMessageFor(model => model.UsePercentage)
@Html.SmartLabelFor(model => model.DiscountAmount) @Html.EditorFor(model => model.DiscountAmount) [@Model.PrimaryStoreCurrencyCode] @Html.ValidationMessageFor(model => model.DiscountAmount)
@Html.SmartLabelFor(model => model.DiscountPercentage) @Html.EditorFor(model => model.DiscountPercentage) @Html.ValidationMessageFor(model => model.DiscountPercentage)
@Html.SmartLabelFor(model => model.StartDateUtc) @Html.EditorFor(model => model.StartDateUtc) @Html.ValidationMessageFor(model => model.StartDateUtc)
@Html.SmartLabelFor(model => model.EndDateUtc) @Html.EditorFor(model => model.EndDateUtc) @Html.ValidationMessageFor(model => model.EndDateUtc)
@Html.SmartLabelFor(model => model.RequiresCouponCode) @Html.EditorFor(model => model.RequiresCouponCode) @Html.ValidationMessageFor(model => model.RequiresCouponCode)
@Html.SmartLabelFor(model => model.CouponCode) @Html.EditorFor(model => model.CouponCode) @Html.ValidationMessageFor(model => model.CouponCode)
@Html.SmartLabelFor(model => model.DiscountLimitationId) @Html.DropDownListFor(model => model.DiscountLimitationId, ((DiscountLimitationType)Model.DiscountLimitationId).ToSelectList()) @Html.ValidationMessageFor(model => model.DiscountLimitationId)
@Html.SmartLabelFor(model => model.LimitationTimes) @Html.EditorFor(model => model.LimitationTimes) @Html.ValidationMessageFor(model => model.LimitationTimes) @T("Admin.Promotions.Discounts.Fields.LimitationTimes.Times")
} @helper TabRequirements() { if (Model.Id > 0) {
@T("Admin.Promotions.Discounts.Requirements.AddNew")
@Html.SmartLabelFor(model => model.AddDiscountRequirement) @Html.DropDownListFor(model => model.AddDiscountRequirement, Model.AvailableDiscountRequirementRules, new { style = "width:480px", data_select_min_results_for_search = 999 }) @Html.ValidationMessageFor(model => model.AddDiscountRequirement)
} else {
@T("Admin.Promotions.Discounts.Requirements.SaveBeforeEdit")
} } @helper TabHistory() { var gridPageSize = EngineContext.Current.Resolve().GridPageSize; @(Html.Telerik().Grid() .Name("usagehistory-grid") .DataKeys(x => { x.Add(y => y.Id).RouteKey("Id"); x.Add(y => y.DiscountId).RouteKey("discountId"); }) .Columns(columns => { columns.Bound(x => x.OrderId) .Width(100) .Template(x => Html.ActionLink("{0} (#{1})".FormatCurrentUI(T("Admin.Common.View").Text, x.OrderId), "Edit", "Order", new { id = x.OrderId }, new { })) .ClientTemplate("\">" + T("Admin.Common.View").Text + " (#<#= OrderId #>)"); columns.Bound(x => x.CreatedOn).Width(200); columns.Command(commands => { commands.Delete().Localize(T); }).Width(100).Title(T("Admin.Common.Delete").Text); }) .Pageable(settings => settings.PageSize(gridPageSize).Position(GridPagerPosition.Both)) .DataBinding(dataBinding => { dataBinding.Ajax().Select("UsageHistoryList", "Discount", new { discountId = Model.Id }) .Delete("UsageHistoryDelete", "Discount"); }) .PreserveGridState() .EnableCustomBinding(true)) }