@model ActivityLogSearchModel

@{
    //page title
    ViewBag.PageTitle = T("Admin.Customers.ActivityLog").Text;
    //active menu item (system name)
    NopHtml.SetActiveMenuItemSystemName("Activity logs");
}

@{
    const string hideSearchBlockAttributeName = "ActivityLogPage.HideSearchBlock";
    var hideSearchBlock = await genericAttributeService.GetAttributeAsync<bool>(await workContext.GetCurrentCustomerAsync(), hideSearchBlockAttributeName);
}

<div class="content-header clearfix">
    <h1 class="float-left">
        @T("Admin.Customers.ActivityLog")
    </h1>
    <div class="float-right">
        <form asp-controller="ActivityLog" asp-action="ClearAll" method="post">
            <button type="submit" id="clearall" name="clearall" class="btn bg-red">
                <i class="far fa-trash-alt"></i>
                @T("Admin.Customers.ActivityLog.Clear")
            </button>
            <nop-action-confirmation asp-button-id="clearall" />
            @await Component.InvokeAsync("AdminWidget", new { widgetZone = AdminWidgetZones.ActivityLogListButtons, additionalData = Model })
        </form>
    </div>

</div>

<section class="content">
    <div class="container-fluid">
    <div class="form-horizontal">
        <div class="cards-group">
            <div class="card card-default card-search">
                <div class="card-body">
                    <div class="row search-row @(!hideSearchBlock ? "opened" : "")" data-hideAttribute="@hideSearchBlockAttributeName">
                        <div class="search-text">@T("Admin.Common.Search")</div>
                        <div class="icon-search"><i class="fas fa-search" aria-hidden="true"></i></div>
                        <div class="icon-collapse"><i class="far fa-angle-@(!hideSearchBlock ? "up" : "down")" aria-hidden="true"></i></div>
                    </div>

                    <div class="search-body @(hideSearchBlock ? "closed" : "")">

                        <div class="row">
                            <div class="col-md-5">
                                <div class="form-group row">
                                    <div class="col-md-4">
                                        <nop-label asp-for="CreatedOnFrom" />
                                    </div>
                                    <div class="col-md-8">
                                        <nop-editor asp-for="CreatedOnFrom" />
                                    </div>
                                </div>
                                <div class="form-group row">
                                    <div class="col-md-4">
                                        <nop-label asp-for="CreatedOnTo" />
                                    </div>
                                    <div class="col-md-8">
                                        <nop-editor asp-for="CreatedOnTo" />
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-7">
                                <div class="form-group row">
                                    <div class="col-md-4">
                                        <nop-label asp-for="ActivityLogTypeId" />
                                    </div>
                                    <div class="col-md-8">
                                        <nop-select asp-for="ActivityLogTypeId" asp-items="Model.ActivityLogType" />
                                    </div>
                                </div>
                                <div class="form-group row">
                                    <div class="col-md-4">
                                        <nop-label asp-for="IpAddress" />
                                    </div>
                                    <div class="col-md-8">
                                        <nop-editor asp-for="IpAddress" />
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="text-center col-12">
                                <button type="button" id="search-log" class="btn btn-primary btn-search">
                                    <i class="fas fa-search"></i>
                                    @T("Admin.Common.Search")
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="card card-default">
                <div class="card-body">
                    <nop-doc-reference asp-string-resource="@T("Admin.Documentation.Reference.ActivityLog", Docs.ActivityLog + Utm.OnAdmin)" />

                    @await Html.PartialAsync("Table", new DataTablesModel
                    {
                        Name = "activityLog-grid",
                        UrlRead = new DataUrl("ListLogs", "ActivityLog", null),
                        UrlDelete = new DataUrl("ActivityLogDelete", "ActivityLog", null),
                        SearchButtonId = "search-log",
                        Length = Model.PageSize,
                        LengthMenu = Model.AvailablePageSizes,
                        Filters = new List<FilterParameter>
                        {
                            new FilterParameter(nameof(Model.CreatedOnTo)),
                            new FilterParameter(nameof(Model.CreatedOnFrom)),
                            new FilterParameter(nameof(Model.IpAddress)),
                            new FilterParameter(nameof(Model.ActivityLogTypeId))
                        },
                        ColumnCollection = new List<ColumnProperty>
                        {
                            new ColumnProperty(nameof(ActivityLogModel.ActivityLogTypeName))
                            {
                                Title = T("Admin.Customers.ActivityLog.Fields.ActivityLogType").Text,
                                Width = "200"
                            },
                            new ColumnProperty(nameof(ActivityLogModel.CustomerEmail))
                            {
                                Title = T("Admin.Customers.ActivityLog.Fields.CustomerEmail").Text,
                                Width = "100",
                                Render = new RenderLink(new DataUrl("~/Admin/Customer/Edit", nameof(ActivityLogModel.CustomerId)))
                            },
                            new ColumnProperty(nameof(ActivityLogModel.IpAddress))
                            {
                                Title = T("Admin.Customers.ActivityLog.Fields.IpAddress").Text,
                                Width = "100"
                            },
                            new ColumnProperty(nameof(ActivityLogModel.Comment))
                            {
                                Title = T("Admin.Customers.ActivityLog.Fields.Comment").Text
                            },
                            new ColumnProperty(nameof(ActivityLogModel.CreatedOn))
                            {
                                Title = T("Admin.Customers.ActivityLog.Fields.CreatedOn").Text,
                                Width = "200",
                                Render = new RenderDate()
                            },
                            new ColumnProperty(nameof(ActivityLogModel.Id))
                            {
                                Title = T("Admin.Common.Delete").Text,
                                Width = "100",
                                Render = new RenderButtonRemove(T("Admin.Common.Delete").Text),
                                ClassName = NopColumnClassDefaults.Button
                            }
                        }
                    })
                </div>
            </div>
        </div>
    </div>
</div>
</section>