Webiant Logo Webiant Logo
  1. No results found.

    Try your search with a different keyword or use * as a wildcard.

Categories.cshtml

@model TaxCategorySearchModel

@{
    //page title
    ViewBag.PageTitle = T("Admin.Configuration.Tax.Categories").Text;
    //active menu item (system name)
    NopHtml.SetActiveMenuItemSystemName("Tax categories");
}

    <div class="content-header clearfix">
        <h1 class="float-left">
            @T("Admin.Configuration.Tax.Categories")
        </h1>
    </div>

<section class="content">
    <div class="container-fluid">
    <div class="form-horizontal">
        <div class="cards-group">
            @await Component.InvokeAsync(typeof(AdminWidgetViewComponent), new { widgetZone = AdminWidgetZones.TaxCategoryListButtons, additionalData = Model })
            <div class="card card-default">
                <div class="card-body">
                    <nop-doc-reference asp-string-resource="@T("Admin.Documentation.Reference.TaxManagement", Docs.TaxManagement + Utm.OnAdmin)" />

                    @await Html.PartialAsync("Table", new DataTablesModel
                    {
                        Name = "tax-categories-grid",
                        UrlRead = new DataUrl("Categories", "Tax", null),
                        UrlDelete = new DataUrl("CategoryDelete", "Tax", null),
                        UrlUpdate = new DataUrl("CategoryUpdate", "Tax", null),
                        Length = Model.PageSize,
                        LengthMenu = Model.AvailablePageSizes,
                        ColumnCollection = new List<ColumnProperty>
                        {
                            new ColumnProperty(nameof(TaxCategoryModel.Name))
                            {
                                Title = T("Admin.Configuration.Tax.Categories.Fields.Name").Text,
                                Width = "300",
                                Editable = true,
                                EditType = EditType.String
                            },
                            new ColumnProperty(nameof(TaxCategoryModel.DisplayOrder))
                            {
                                Title = T("Admin.Configuration.Tax.Categories.Fields.DisplayOrder").Text,
                                Width = "100",
                                ClassName = NopColumnClassDefaults.CenterAll,
                                Editable = true,
                                EditType = EditType.Number
                            },
                            new ColumnProperty(nameof(TaxCategoryModel.Id))
                            {
                                Title = T("Admin.Common.Edit").Text,
                                Width = "200",
                                ClassName =  NopColumnClassDefaults.Button,
                                Render = new RenderButtonsInlineEdit()
                            },
                            new ColumnProperty(nameof(TaxCategoryModel.Id))
                            {
                                Title = T("Admin.Common.Delete").Text,
                                Width = "100",
                                Render = new RenderButtonRemove(T("Admin.Common.Delete").Text),
                                ClassName = NopColumnClassDefaults.Button
                            }
                        }
                    })

                    <div class="card card-default">
                        <div class="card-header">
                            @T("Admin.Common.AddNewRecord")
                        </div>
                        <div class="card-body">
                            <div class="form-group row">
                                <div class="col-md-3">
                                    <nop-label asp-for="@Model.AddTaxCategory.Name" />
                                </div>
                                <div class="col-md-9">
                                    <nop-editor asp-for="@Model.AddTaxCategory.Name" />
                                    <span asp-validation-for="@Model.AddTaxCategory.Name"></span>
                                </div>
                            </div>
                            <div class="form-group row">
                                <div class="col-md-3">
                                    <nop-label asp-for="@Model.AddTaxCategory.DisplayOrder" />
                                </div>
                                <div class="col-md-9">
                                    <nop-editor asp-for="@Model.AddTaxCategory.DisplayOrder" />
                                    <span asp-validation-for="@Model.AddTaxCategory.DisplayOrder"></span>
                                </div>
                            </div>
                            <div class="form-group row">
                                <div class="col-md-9 offset-md-3">
                                    <button type="button" id="addTaxCategory" class="btn btn-primary">@T("Admin.Common.AddNewRecord")</button>
                                </div>
                            </div>
                        </div>
                        <script>
                            $(function() {
                                $('#addTaxCategory').click(function () {
                                    $('#addTaxCategory').attr('disabled', true);
                                    var postData = {
                                        Name: $("#@Html.IdFor(model => model.AddTaxCategory.Name)").val(),
                                        DisplayOrder: $("#@Html.IdFor(model => model.AddTaxCategory.DisplayOrder)").val()
                                    };
                                    addAntiForgeryToken(postData);

                                    $.ajax({
                                        cache: false,
                                        type: "POST",
                                        url: "@Html.Raw(Url.Action("CategoryAdd", "Tax", null))",
                                        data: postData,
                                        success: function (data, textStatus, jqXHR) {
                                            if (data.Result) {
                                                //reload grid
                                                updateTable('#tax-categories-grid');

                                                //clear input value
                                                $("#@Html.IdFor(model => model.AddTaxCategory.Name)").val('');
                                                $("#@Html.IdFor(model => model.AddTaxCategory.DisplayOrder)").val(0);
                                            } else {
                                                //display errors if returned
                                                display_nop_error(data);
                                            }
                                        },
                                        complete: function (jqXHR, textStatus) {
                                            $('#addTaxCategory').attr('disabled', false);
                                        }
                                    });
                                });
                            });
                        </script>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</section>