@model PantheonApi.SyncApi.Models.ServerScheduleItemVM

@{
    Layout = null;
}

<div id="ServerScheduleEdit">
    @using (Ajax.BeginForm("EditServerSchedule", "SyncSchedules",
                   new AjaxOptions { UpdateTargetId = "ServerScheduleEdit", OnBegin = "startLoading('ServerScheduleEdit')" }))
    {
        @Html.AntiForgeryToken()

        <div class="form-horizontal">

            @if (TempData["Edit-ServerSchedule"] != null)
            {
                <div class="alert alert-danger no-border">
                    <button type="button" class="close" data-dismiss="alert"><span>×</span><span class="sr-only">Close</span></button>
                    <span class="text-semibold">@TempData["Edit-ServerSchedule"]</span>
                </div>
            }

            @Html.ValidationSummary(true, "", new { @class = "text-danger" })
            @Html.HiddenFor(model => model.anQId)
            @Html.HiddenFor(model => model.anScheduleId)

            <div class="row">
                <div class="col-md-6">
                    <div class="form-group">
                        @Html.LabelFor(model => model.acDocType, "Doc type", htmlAttributes: new { @class = "control-label col-md-3" })
                        <div class="col-md-9">
                            @Html.EditorFor(model => model.acDocType, new { htmlAttributes = new { @class = "form-control", @maxlength = "4" } })
                            @Html.ValidationMessageFor(model => model.acDocType, "", new { @class = "text-danger" })
                        </div>
                    </div>

                    <div class="form-group">
                        @Html.LabelFor(model => model.adSyncStartTime, "Start", htmlAttributes: new { @class = "control-label col-md-3" })
                        <div class="col-md-9">
                            @Html.EditorFor(model => model.adSyncStartTime, new { htmlAttributes = new { @class = "form-control datetimepicker" } })
                            @Html.ValidationMessageFor(model => model.adSyncStartTime, "", new { @class = "text-danger" })
                        </div>
                    </div>


                    <div class="form-group">
                        @Html.LabelFor(model => model.ScheduleType, "Schedule Type", htmlAttributes: new { @class = "control-label col-md-3" })
                        <div class="col-md-9">
                            <label class="col-md-12">
                                @Html.RadioButtonFor(model => model.ScheduleType, ScheduleType.Manual, htmlAttributes: new { @onchange = "scheduleType()" })
                                @ScheduleType.Manual
                            </label>
                            <label class="col-md-12">
                                @Html.RadioButtonFor(model => model.ScheduleType, ScheduleType.Daily, htmlAttributes: new { @onchange = "scheduleType()" })
                                @ScheduleType.Daily
                            </label>
                            <label class="col-md-12">
                                @Html.RadioButtonFor(model => model.ScheduleType, ScheduleType.Hourly, htmlAttributes: new { @onchange = "scheduleType()" })
                                @ScheduleType.Hourly
                            </label>
                        </div>
                    </div>
                </div>
                <div class="col-md-6 manual-schedule">
                    <div class="form-group">
                        @Html.LabelFor(model => model.adNextSyncTime, "Next sync", htmlAttributes: new { @class = "control-label col-md-3" })
                        <div class="col-md-9">
                            @Html.EditorFor(model => model.adNextSyncTime, new { htmlAttributes = new { @class = "form-control datetimepicker" } })
                            @Html.ValidationMessageFor(model => model.adNextSyncTime, "", new { @class = "text-danger" })
                        </div>
                    </div>

                    <div class="form-group">
                        @Html.LabelFor(model => model.anTimePeriod, "Time period", htmlAttributes: new { @class = "control-label col-md-3" })
                        <div class="col-md-9">
                            @Html.EditorFor(model => model.anTimePeriod, new { htmlAttributes = new { @class = "form-control" } })
                            @Html.ValidationMessageFor(model => model.anTimePeriod, "", new { @class = "text-danger" })
                        </div>
                    </div>
                </div>
            </div>

            <div class="form-group">
                <div class="text-right">
                    @Ajax.ActionLink("Cancel", "ServerSchedules", "SyncSchedules",
                   new { scheduleId = Model.anScheduleId },
                new AjaxOptions
                {
                    UpdateTargetId = "ServerScheduleEdit",
                    InsertionMode = InsertionMode.Replace,
                    OnBegin = "startLoading('ServerScheduleEdit')"
                }, new { @class = "btn btn-default" })
                    <input type="submit" value="Save" class="btn btn-success" />
                </div>
            </div>
        </div>
    }
    <script>
        dateTimePicker();
        scheduleType();
    </script>
</div>
    
