ildar-shaymukhametov_grandnode-refactorings/Grand.Web/Areas/Admin/Views/Customer/_CreateOrUpdate.TabActivityLog.cshtml
@model CustomerModel
@inject AdminAreaSettings adminAreaSettings
@inject Grand.Services.Security.IPermissionService permisionService
@{
    var defaultGridPageSize = adminAreaSettings.DefaultGridPageSize;
    var gridPageSizes = adminAreaSettings.GridPageSizes;

    <strong>@T("Admin.Configuration.Activitylog")</strong>
    <div class="panel panel-default">
        <vc:admin-widget widget-zone="customer_details_activity_log_top" additional-data="Model" />
        <div class="panel-body">
            <div id="activitylog-grid"></div>
        </div>
        <vc:admin-widget widget-zone="customer_details_activity_log_bottom" additional-data="Model" />
    </div>

    <script>
        $(document).ready(function () {
            $("#activitylog-grid").kendoGrid({
                dataSource: {
                    transport: {
                        read: {
                            url: "@Html.Raw(Url.Action("ListActivityLog", "Customer", new { customerId = Model.Id }))",
                            type: "POST",
                            dataType: "json",
                            data: addAntiForgeryToken
                        }
                    },
                    schema: {
                        data: "Data",
                        total: "Total",
                        errors: "Errors"
                    },
                    error: function(e) {
                        display_kendoui_grid_error(e);
                        // Cancel the changes
                        this.cancelChanges();
                    },
                    pageSize: @(defaultGridPageSize),
                    serverPaging: true,
                    serverFiltering: true,
                    serverSorting: true
                },
                pageable: {
                    refresh: true,
                    pageSizes: [@(gridPageSizes)]
                },
                editable: {
                    confirmation: false,
                    mode: "inline"
                },
                scrollable: false,
                columns: [{
                    field: "ActivityLogTypeName",
                    title: "@T("Admin.Customers.Customers.ActivityLog.ActivityLogType")",
                    width: 140,
                }, {
                    field: "Comment",
                    title: "@T("Admin.Customers.Customers.ActivityLog.Comment")",
                    width: 250,
                }, {
                    field: "CreatedOn",
                    title: "@T("Admin.Customers.Customers.ActivityLog.CreatedOn")",
                    width: 120,
                    type: "date",
                    format: "{0:G}"
                }, {
                    field: "IpAddress",
                    title: "@T("Admin.Customers.Customers.ActivityLog.IpAddress")",
                    width: 50,
                }]
            });
        });
    </script>

    if (Model.ShowMessageContactForm)
    {
        <br />
        <strong>@T("Admin.System.ContactForm")</strong>

        <div class="panel panel-default">
            <div class="panel-body">
                <div id="contactform-grid"></div>
            </div>
        </div>
        <script>
            $(document).ready(function () {
                $("#contactform-grid").kendoGrid({
                    dataSource: {
                        transport: {
                            read: {
                                url: "@Html.Raw(Url.Action("ContactFormList", "Customer", new { customerId = Model.Id }))",
                                type: "POST",
                                dataType: "json",
                                data: addAntiForgeryToken
                            }
                        },
                        schema: {
                            data: "Data",
                            total: "Total",
                            errors: "Errors"
                        },
                        error: function(e) {
                            display_kendoui_grid_error(e);
                            // Cancel the changes
                            this.cancelChanges();
                        },
                        pageSize: @(defaultGridPageSize),
                        serverPaging: true,
                        serverFiltering: true,
                        serverSorting: true
                    },
                    pageable: {
                        refresh: true,
                        pageSizes: [@(gridPageSizes)]
                    },
                    scrollable: false,
                    columns: [{
                        field: "CreatedOn",
                        title: "@T("Admin.System.ContactForm.Fields.CreatedOn")",
                        width: 100,
                        type: "date",
                        format: "{0:G}"
                    }, {
                        field: "Store",
                        title: "@T("Admin.System.ContactForm.Fields.Store")",
                        width: 100
                    }, {
                        field: "Email",
                        title: "@T("Admin.System.ContactForm.Fields.FullName")",
                        width: 150
                    }, {
                        field: "IpAddress",
                        title: "@T("Admin.System.ContactForm.Fields.IpAddress")",
                        width: 50
                    }, {
                        field: "Subject",
                        title: "@T("Admin.System.ContactForm.Fields.Subject")",
                        width: 300
                    }, {
                        field: "Id",
                        title: "@T("Admin.Common.View")",
                        width: 30,
                        template: '<a href="@Url.Action("Details", "ContactForm")/#=Id#">@T("admin.common.view")</a>'
                    }]
                });
            });
        </script>
    }

    @if (await permisionService.Authorize(Grand.Services.Security.PermissionSystemName.MessageQueue))
    {
        <br />
        <strong>@T("Admin.System.QueuedEmails")</strong>

        <div class="panel panel-default">
            <div class="panel-body">
                <div id="queuedEmails-grid"></div>
            </div>
        </div>
        <script>
            function queadditionalData() {
                var data = {
                    SearchToEmail: $('#@Html.FieldIdFor(model => model.Email)').val(),
                    SearchStartDate: '',
                    SearchEndDate: '',
                    SearchFromEmail: '',
                    SearchLoadNotSent: false,
                    SearchMaxSentTries: 10
                };
                addAntiForgeryToken(data);
                return data;
            }
            $(document).ready(function () {
                $("#queuedEmails-grid").kendoGrid({
                    dataSource: {
                        transport: {
                            read: {
                                url: "@Html.Raw(Url.Action("QueuedEmailList", "QueuedEmail"))",
                                type: "POST",
                                dataType: "json",
                                data: queadditionalData
                            }
                        },
                        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)]
                    },
                    scrollable: false,
                    columns: [{
                        field: "Subject",
                        title: "@T("Admin.System.QueuedEmails.Fields.Subject")",
                        width: 300,
                        template: '<a class="k-link" href="@Url.Action("Edit", "QueuedEmail")/#=Id#">#=kendo.htmlEncode(Subject)#</a>'
                    }, {
                        field: "CreatedOn",
                        title: "@T("Admin.System.QueuedEmails.Fields.CreatedOn")",
                        width: 100,
                        type: "date",
                        format: "{0:G}"
                    }, {
                        field: "SentOn",
                        title: "@T("Admin.System.QueuedEmails.Fields.SentOn")",
                        width: 100,
                        type: "date",
                        format: "{0:G}"
                    }, {
                        field: "PriorityName",
                        title: "@T("Admin.System.QueuedEmails.Fields.Priority")",
                        width: 50
                    }]
                });
            });
        </script>
    }

}