@model PagedList.IPagedList<PantheonApi.SyncApi.Models.ServerScheduleItemVM>
@using PagedList.Mvc;
@{
    Layout = null;
}

<div id="ServerScheduleList">
    <div class="text-right">
        <a data-ajax-begin="startLoading('ServerScheduleList')"
           data-ajax="true"
           data-ajax-mode="replace"
           data-ajax-update="#ServerScheduleList"
           href="@Url.Action("CreateServerSchedule", "SyncSchedules", new { scheduleId = ViewBag.ScheduleId })"
           class="btn btn-success"
           title="New"><i class="glyphicon glyphicon-plus"></i></a>
    </div>
    <div class="table-responsive">
        <table class="table table-hover table-striped">
            <thead>
                <tr>
                    <th>
                        Schedule ID
                    </th>
                    <th>
                        Doc type
                    </th>
                    <th>
                        Start time
                    </th>
                    <th>
                        Next sync
                    </th>
                    <th>
                        Time period (min)
                    </th>
                    <th></th>
                    <th></th>
                </tr>
            </thead>
            <tbody>
                @foreach (var item in Model)
                {
                    <tr>
                        <td>
                            @Html.DisplayFor(modelItem => item.anScheduleId)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.acDocType)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.adSyncStartTime)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.adNextSyncTime)
                        </td>
                        <td>
                            @(item.ScheduleType == ScheduleType.Manual ? item.anTimePeriod.ToString() : item.ScheduleType.ToString())
                        </td>
                        <td class="text-center">
                            <a data-ajax-begin="startLoading('ServerScheduleList')"
                               data-ajax="true"
                               data-ajax-mode="replace"
                               data-ajax-update="#ServerScheduleList"
                               href="/SyncSchedules/DeleteServerSchedule?id=@item.anQId"
                               class="text-danger"
                               title="Remove"><i class="glyphicon glyphicon-remove"></i></a>
                        </td>
                        <td class="text-center">
                            <a data-ajax-begin="startLoading('ServerScheduleList')"
                               data-ajax="true"
                               data-ajax-mode="replace"
                               data-ajax-update="#ServerScheduleList"
                               href="/SyncSchedules/EditServerSchedule?id=@item.anQId"
                               class="text-info"
                               title="Edit"><i class="glyphicon glyphicon-pencil"></i></a>
                        </td>
                    </tr>
                }
            </tbody>
        </table>
        <br />

        <div class="text-center">
            @Html.PagedListPager(Model, page => Url.Action("ServerSchedules", "SyncSchedules", new { page, scheduleId = ViewBag.ScheduleId }),
                        PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing(new AjaxOptions()
                        {
                            HttpMethod = "GET",
                            UpdateTargetId = "ServerScheduleList"
                        }))
        </div>
    </div>
</div>