ildar-shaymukhametov_grandnode-refactorings/Grand.Web/Areas/Admin/Views/Reports/NeverSoldReport.cshtml
@model NeverSoldReportModel
@inject AdminAreaSettings adminAreaSettings
@{
    //page title
    ViewBag.Title = T("Admin.Reports.NeverSold").Text;
}

<div class="row">
    <div class="col-md-12">
        <div class="x_panel light form-fit">
            <div class="x_title">
                <div class="caption level-caption">
                    <i class="fa fa-list-alt"></i>
                    @T("Admin.Reports.NeverSold")
                </div>
            </div>
            <div class="x_content form">
                <vc:admin-widget widget-zone="never_sold_report" additional-data="Model" />
                <div class="form-horizontal">
                    <div class="form-body">
                        <div class="x_content">
                            <div class="form-horizontal">
                                <div class="form-body">
                                    <div class="form-group">
                                        <admin-label asp-for="StartDate" />
                                        <div class="col-md-9 col-sm-9">
                                            <admin-input asp-for="StartDate" />
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <admin-label asp-for="EndDate" />
                                        <div class="col-md-9 col-sm-9">
                                            <admin-input asp-for="EndDate" />
                                        </div>
                                    </div>
                                </div>
                                <div class="form-actions">
                                    <div class="row">
                                        <div class="offset-md-3 offset-sm-3 col-md-9 col-sm-9">
                                            <button class="btn btn-success filter-submit" id="search-neversoldreport">
                                                <i class="fa fa-search"></i> @T("Admin.Reports.NeverSold.RunReport")
                                            </button>
                                        </div>
                                    </div>
                                </div>
                                <div class="x_content">
                                    <div id="neversoldreport-grid"></div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<script>
    $(document).ready(function () {
        $("#neversoldreport-grid").kendoGrid({
            dataSource: {
                transport: {
                    read: {
                        url: "@Html.Raw(Url.Action("NeverSoldReportList", "Reports"))",
                        type: "POST",
                        dataType: "json",
                        data: additionalData
                    }
                },
                schema: {
                    data: "Data",
                    total: "Total",
                    errors: "Errors"
                },
                error: function(e) {
                    display_kendoui_grid_error(e);
                    // Cancel the changes
                    this.cancelChanges();
                },
                pageSize: @(adminAreaSettings.DefaultGridPageSize),
                serverPaging: true,
                serverFiltering: true,
                serverSorting: true
            },
            pageable: {
                refresh: true,
                pageSizes: [@(adminAreaSettings.GridPageSizes)]
            },
            editable: {
                confirmation: false,
                mode: "inline"
            },
            scrollable: false,
            columns: [{
                field: "ProductName",
                title: "@T("Admin.Reports.NeverSold.Fields.Name")",
                template: '<a class="k-link" href="@Url.Action("Edit", "Product")/#=ProductId#">#=kendo.htmlEncode(ProductName)#</a>'
            }]
        });
    });
</script>
<script>

    $(document).ready(function () {

        $('#search-neversoldreport').click(function () {
            var grid = $('#neversoldreport-grid').data('kendoGrid');
            grid.dataSource.page(1); //new search. Set page size to 1
            //grid.dataSource.read(); we already loaded the grid above using "page" function
            return false;
        });

    });

    function additionalData() {
        var data = {
            StartDate: $('#@Html.FieldIdFor(model => model.StartDate)').val(),
            EndDate: $('#@Html.FieldIdFor(model => model.EndDate)').val()
        };
        addAntiForgeryToken(data);
        return data;
    }

</script>
