@using X.PagedList;
@using X.PagedList.Mvc.Core;
@using X.PagedList.Web.Common;

@model IPagedList<Project>

<table class="table table-striped table-hover"
       data-filter-control="true"
       data-show-search-clear-button="true">
    <thead>
        <tr>
            <th>
                @Html.DisplayNameFor(x => x.GetEnumerator().Current.No)
            </th>
            <th>
                @Html.DisplayNameFor(x => x.GetEnumerator().Current.Plant)
            </th>
            <th>
                @Html.DisplayNameFor(x => x.GetEnumerator().Current.Name)
            </th>
            <th>
                @Html.DisplayNameFor(x => x.GetEnumerator().Current.Description)
            </th>
            <th>
                @Html.DisplayNameFor(x => x.GetEnumerator().Current.Status)
            </th>
            <th>
                <a onclick="showInPopup('@Url.Action("AddOrEdit", "Project",null, Context.Request.Scheme)','neu')" class="btn btn-success text-white">
                    <i class="bi bi-plus-square"></i>
                    neues Projekt erstellen
                </a>
            </th>
        </tr>
    </thead>

    <tbody>
        @{
            foreach (var item in Model)
            {
                <tr>
                    <td hidden>
                        @Html.DisplayFor(modelItem => item.Id)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.No)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => @item.Plant.Name)  @Html.DisplayFor(modelItem => @item.Plant.SubPlantShortName)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => @item.Name)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => @item.Description)
                    </td>
                    <td class="text-@(item.Status == ProjectStatus.started ? "success" : "danger")">
                        @Html.DisplayFor(modelItem => @item.Status)
                    </td>
                    <td>
                        <div class="btn-group" style="flex-direction:row">                            
                            <a onclick="showInPopup('@Url.Action("AddOrEdit", "Project",new {id = item.Id}, Context.Request.Scheme)','Projekt bearbeiten')" class="btn btn-success text-white">
                                <i class="bi bi-pencil-square"></i>                                
                            </a>
                            <a asp-action="Delete" asp-asp-route-id="@item.Id"><i class="bi bi-trash"></i></a>
                            @* <button class="btn btn-success" onclick="location.href='@Url.Action("CreateEdit", new {@item.Id})'"><i class="bi bi-pencil-square"></i></button>
                             <button class="btn btn-danger" onclick="location.href='@Url.Action("DeleteProject", new {@item.Id})'"><i class="bi bi-trash"></i></button>*@
                        </div>
                    </td>
                </tr>
            }
        }
   </tbody>

</table>


<nav>
    @Html.PagedListPager(Model, page => Url.Action("index", new { page = page }), new PagedListRenderOptions()
    {
    ActiveLiElementClass = "active",
    PageClasses = new[]{ "page-link"},
    LiElementClasses=new[] { "page-item" },
    UlElementClasses = new[] { "pagination","justify-content-center", "mt-3" },
    LinkToNextPageFormat = ">",
    LinkToPreviousPageFormat = "<",
    DisplayLinkToPreviousPage = PagedListDisplayMode.Always,
    DisplayLinkToNextPage = PagedListDisplayMode.Always
    })
</nav>
