ildar-shaymukhametov_grandnode-refactorings/Grand.Web/Areas/Admin/Views/Reports/CountryReport.cshtml
@model CountryReportModel
@{
    //page title
    ViewBag.Title = T("Admin.Reports.Country").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.Country")
                </div>

            </div>
            <div class="x_content form">
                <vc:admin-widget widget-zone="country_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 class="form-group">
                                        <admin-label asp-for="OrderStatusId" />
                                        <div class="col-md-9 col-sm-9">
                                            <admin-select asp-for="OrderStatusId" asp-items="Model.AvailableOrderStatuses" />
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <admin-label asp-for="PaymentStatusId" />
                                        <div class="col-md-9 col-sm-9">
                                            <admin-select asp-for="PaymentStatusId" asp-items="Model.AvailablePaymentStatuses" />
                                        </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-countryreport">
                                                <i class="fa fa-search"></i> @T("Admin.Reports.Country.RunReport")
                                            </button>
                                        </div>
                                    </div>
                                </div>
                                <div class="x_content">
                                    <div id="countryreport-grid"></div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


    <script>
        $(document).ready(function () {
            $("#countryreport-grid").kendoGrid({
                dataSource: {
                    transport: {
                        read: {
                            url: "@Html.Raw(Url.Action("CountryReportList", "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();
                    },
                    serverPaging: true,
                    serverFiltering: true,
                    serverSorting: true
                },
                pageable: {
                    refresh: true,
                    numeric: false,
                    previousNext: false,
                    info: false
                },
                scrollable: false,
                columns: [{
                    field: "CountryName",
                    title: "@T("Admin.Reports.Country.Fields.CountryName")"
                }, {
                    field: "TotalOrders",
                    title: "@T("Admin.Reports.Country.Fields.TotalOrders")"
                },{
                    field: "SumOrders",
                    title: "@T("Admin.Reports.Country.Fields.SumOrders")"
                }]
            });
        });
    </script>

    <script>

        $(document).ready(function () {

            $('#search-countryreport').click(function () {
                var grid = $('#countryreport-grid').data('kendoGrid');
                grid.dataSource.read();
                return false;
            });

        });

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

    </script>
