ildar-shaymukhametov_grandnode-refactorings/Grand.Web/Areas/Admin/Views/Home/Statistics.cshtml
@model DashboardModel
@inject Grand.Services.Security.IPermissionService permissionService

@{
    //page title
    ViewBag.Title = T("Admin.Dashboard.Statistics").Text;
    var canManageOrders = await permissionService.Authorize(Grand.Services.Security.StandardPermissionProvider.ManageOrders);
    var canManageCustomers = await permissionService.Authorize(Grand.Services.Security.StandardPermissionProvider.ManageCustomers);
    var canManageProducts = await permissionService.Authorize(Grand.Services.Security.StandardPermissionProvider.ManageProducts);
}

<div class="page-bar" style="height:43px;">
    <div class="page-toolbar">
        <div id="dashboard-report-range" class="pull-right btn btn-sm">
            <i class="icon-calendar"></i>&nbsp;
            <span class="thin uppercase">@DateTime.Now.ToLocalTime().ToString()</span>&nbsp;
        </div>
    </div>
</div>
<div class="content-header">
    <h3 class="page-title">
        <i class="icon-bulb"></i>
        @T("Admin.Dashboard")
        <small>@T("Admin.Dashboard.Statistics")</small>
    </h3>
</div>

<div class="content">
    <div class="row">
        <div class="col-md-12">
            @if (!Model.IsLoggedInAsVendor && canManageOrders)
            {
                <div class="row">
                    <div class="col-md-12">
                        <div class="x_panel">
                            <div class="x_title">
                                <div class="caption level-caption">
                                    <span class="caption-subject font-dark bold uppercase">@T("Admin.Reports.Average")</span>
                                </div>
                            </div>
                            <div class="x_content">
                                @await Component.InvokeAsync("OrderOrderAverageReport")
                            </div>
                        </div>
                    </div>
                </div>
            }
            @if (!Model.IsLoggedInAsVendor)
            {
                if (canManageOrders || canManageCustomers || canManageProducts)
                {
                    <div class="row">
                        @if (canManageOrders)
                        {
                            <div class="col-md-6">
                                <div class="x_panel">
                                    <div class="x_title">
                                        <div class="caption level-caption">
                                            <span class="caption-subject font-dark bold uppercase">@T("Admin.Reports.Incomplete")</span>
                                        </div>
                                    </div>
                                    <div class="x_content">
                                        @await Component.InvokeAsync("OrderOrderIncompleteReport")
                                    </div>
                                </div>
                            </div>
                        }

                        @if (canManageOrders)
                        {
                            <div class="col-md-6">
                                <div class="x_panel">
                                    <div class="x_title">
                                        <div class="caption level-caption">
                                            <span class="caption-subject font-dark bold uppercase">@T("Admin.Reports.Customers.RegisteredCustomers")</span>
                                        </div>
                                    </div>
                                    <div class="x_content">
                                        @await Component.InvokeAsync("CustomerReportRegisteredCustomers")
                                    </div>
                                </div>
                            </div>
                        }
                    </div>
                    <div class="row">
                        @if (canManageProducts)
                        {
                            <div class="col-md-6">
                                <div class="x_panel">
                                    <div class="x_title">
                                        <div class="caption level-caption">
                                            <span class="caption-subject font-dark bold uppercase">@T("Admin.SearchTermReport")</span>
                                        </div>
                                    </div>
                                    <div class="x_content">
                                        @await Component.InvokeAsync("CommonPopularSearchTermsReport")
                                    </div>
                                </div>
                            </div>
                        }
                        @if (canManageOrders)
                        {
                            <div class="col-md-6">
                                <div class="x_panel">
                                    <div class="x_title">
                                        <div class="caption level-caption">
                                            <span class="caption-subject font-dark bold uppercase">@T("Admin.Reports.Period")</span>
                                        </div>
                                    </div>
                                    <div class="x_content">
                                        @await Component.InvokeAsync("OrderOrderPeriodReport")
                                    </div>
                                </div>
                            </div>
                        }

                    </div>
                }
            }

            @if (canManageOrders)
            {
                <div class="row">
                    <div class="col-md-6">
                        <div class="x_panel">
                            <div class="x_title">
                                <div class="caption level-caption">
                                    <span class="caption-subject font-dark bold uppercase">@T("Admin.Reports.BestSellers.ByQuantity")</span>
                                </div>
                            </div>
                            <div class="x_content">
                                @await Component.InvokeAsync("OrderBestsellersBriefReportByQuantity")
                            </div>
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="x_panel">
                            <div class="x_title">
                                <div class="caption level-caption">
                                    <span class="caption-subject font-dark bold uppercase">@T("Admin.Reports.BestSellers.ByAmount")</span>
                                </div>
                            </div>
                            <div class="x_content">
                                @await Component.InvokeAsync("OrderBestsellersBriefReportByAmount")
                            </div>
                        </div>
                    </div>
                </div>
            }
        </div>
    </div>
</div>