@model PantheonRA.BackOffice.Models.TimeRecordModalViewModel
@using PantheonRA.BackOffice.Enums
@using PantheonRA.WebApi.Contracts

@{
    var currentDate = DateTime.Now;
    var currentDateMidnight = new DateTime(currentDate.Year, currentDate.Month, currentDate.Day, 0, 0, 0);
    var absenceHelpUrl = string.Format("{0}{1}", Loc.HelpUrl, HelpIds.TimeRecordsNewAbsence);
    var absenceHelpExampleUrl = string.Format("{0}{1}", Loc.HelpUrl, HelpIds.ExampleTimeRecordsNewAbsence);
    var obligationHelpUrl = string.Format("{0}{1}", Loc.HelpUrl, HelpIds.TimeRecordsNewRecord);
    var obligationHelpExampleUrl = string.Format("{0}{1}", Loc.HelpUrl, HelpIds.ExampleTimeRecordsNewRecord);
}

@Html.Hidden("AbsenceHelpUrl", absenceHelpUrl)
@Html.Hidden("AbsenceHelpExampleUrl", absenceHelpExampleUrl)
@Html.Hidden("AddOrDeleteAbsence", Loc.AddOrDeleteAbsence)
@Html.Hidden("AbsenceType", Loc.AbsenceType)
@Html.Hidden("AbsenceStart", Loc.AbsenceStart)
@Html.Hidden("AbsenceEnd", Loc.AbsenceEnd)

@Html.Hidden("ObligationHelpUrl", obligationHelpUrl)
@Html.Hidden("ObligationHelpExampleUrl", obligationHelpExampleUrl)
@Html.Hidden("AddOrDeleteWorkCommitment", Loc.AddOrDeleteWorkCommitment)
@Html.Hidden("ObligationType", Loc.ObligationType)
@Html.Hidden("ObligationStart", Loc.TaBegin)
@Html.Hidden("ObligationEnd", Loc.TaEnd)
@Html.Hidden("AddNewObligation", Loc.Add)
@Html.Hidden("ModelWorker", Model.Worker)
@Html.Hidden("DeleteAbsenceCompleted", Loc.DeleteAbsenceCompleted)
@Html.Hidden("StatusResponseMessageOk", StatusResponseMessage.Ok)


<div class="modal" id="newrecord-modal" role="dialog" aria-hidden="true">
    <div class="modal-dialog ta-modal-size">
        <div class="modal-content">
            <div class="modal-header">
                <form id="NewRecordForm" action="@Url.Action("EnterNewRecord", "TimeRecords")" method="post">
                    <input type="hidden" name="Absence" id="Absence" value="" />

                    <div class="row" style="padding:0px 15px">
                        <div>
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                            <a id="newrecord-help-url" href="@Loc.HelpUrl@HelpIds.TimeRecordsNewRecord"
                               target="_blank" class="pull-right m-r-sm default-icon-color"><i class="fa fa-question"></i></a>
                            <a id="newrecord-help-example-url" class="btn-transparent pull-right m-r-sm default-icon-color" href="@SiteHelpAttributeHelper.GetHelpUrl(HelpIds.ExampleTimeRecordsNewRecord)" target="_blank" title="@Loc.CheckInstructions">
                                <i class="fas fa-book-reader clickable-icon"></i>
                            </a>
                            <h3 id="newrecord-modal-title">@Loc.AddOrDeleteWorkCommitment</h3>
                        </div>

                        <div class="row">
                            <div class="col-sm-3 m-t-sm p-r-0">
                                @Html.Label("Workers", Loc.Worker, new { @class = "control-label" })
                            </div>
                            <div class="col-sm-9 p-l-0">
                                @Html.DropDownList("Workers",
                                    new SelectList(Model.TimeRecordsFilterData.Employees.Where(x => x.Active == ActiveStatus.Active), "WorkerCode", "WorkerName", Model.Worker), Loc.All,
                                    HtmlAttributesHelper.CreateInputAttributes("form-control selectpicker",
                                        "NewRecordEmployee", false, Loc.Worker, true,
                                        new { @multiple = "multiple", @title = Loc.Worker, data_live_search = "true", @name = "Workers" }))
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-sm-3 m-t-sm p-r-0">
                                <label id="newrecord-modal-type">@Loc.ObligationType</label>
                            </div>
                            <div id="dynamic-type-div" class="col-sm-9 p-l-0">
                                <select id="Type"
                                        name="Type"
                                        data-placeholder="@Loc.SelectType"
                                        class="form-control select2withAPI"
                                        filter-by="EntryTypeNumber"
                                        data-search-width="250"
                                        data-url=@Url.Action("GetDropDownValues", "GlobalHelper", new { apiPath = "/v1/calendar-entry-types/icon-types/" })>
                                    <option value=""></option>
                                </select>
                                <span class="field-validation-error text-danger hidden m-l-sm" id="type-validation">@Loc.RequiredInput</span>
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-sm-3 m-t-sm p-r-0">
                                <label id="newrecord-modal-begin">@Loc.TaBegin</label>
                            </div>
                            <div class="col-sm-9 p-l-0">
                                <div class="input-group">
                                    <span class="input-group-addon" style="padding-left:11px"><i class="far fa-calendar alt"></i></span>
                                    <input type="text"
                                           id="NewRecordStartDate"
                                           name="DateStart"
                                           value="@currentDateMidnight"
                                           class="form-control new-record-datetimepicker" />
                                </div>
                                <span class="field-validation-error text-danger hidden m-l-sm" id="timestart-validation">@Loc.RequiredInput</span>
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-sm-3 m-t-sm p-r-0">
                                <label id="newrecord-modal-end">@Loc.TaEnd</label>
                            </div>
                            <div class="col-sm-9 p-l-0">
                                <div class="input-group">
                                    <span class="input-group-addon" style="padding-left:11px"><i class="far fa-calendar alt"></i></span>
                                    <input type="text"
                                           id="NewRecordEndDate"
                                           name="DateEnd"
                                           value="@currentDateMidnight"
                                           class="form-control new-record-datetimepicker" />
                                </div>
                                <span class="field-validation-error text-danger hidden m-l-sm" id="timeend-validation">@Loc.RequiredInput</span>
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-sm-3 m-t-sm p-r-0">
                                <label>@Loc.Department</label>
                            </div>
                            <div class="col-sm-9 p-l-0">
                                <select id="DepartmentModal"
                                        name="Department"
                                        data-placeholder="@Loc.Department"
                                        class="form-control select2withAPI"
                                        data-url=@Url.Action("GetDropDownValues", "GlobalHelper", new { apiPath = "/v1/time-records/departments" })>
                                    <option value=""></option>
                                </select>
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-sm-3 m-t-sm p-r-0">
                                <label>@Loc.CostCarrier</label>
                            </div>
                            <div class="col-sm-9 p-l-0">
                                <select id="CostDrvModal"
                                        name="CostDrv"
                                        data-placeholder="@Loc.CostCarrier"
                                        class="form-control select2withAPI"
                                        data-url=@Url.Action("GetDropDownValues", "GlobalHelper", new { apiPath = "/v1/time-records/cost-drivers" })>
                                    <option value=""></option>
                                </select>
                            </div>
                        </div>

                        <div id="newrecord-modal-statuses" class="row hidden">
                            <div class="col-sm-3 m-t-sm p-r-0">
                                <label>@Loc.Status</label>
                            </div>
                            <div class="col-sm-9 p-l-0">
                                <select id="Status"
                                        name="Status"
                                        data-placeholder="@Loc.Status"
                                        class="form-control select2withAPI"
                                        data-url=@Url.Action("GetEmployeeStatuses", "Employees")>
                                    <option value=""></option>
                                </select>
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-sm-3 m-t-sm p-r-0">
                                <label>@Loc.Note</label>
                            </div>
                            <div class="col-sm-9 p-l-0">
                                <div class="form-group" style="margin-bottom:0px">
                                    <input id="Note"
                                           name="Note"
                                           class="form-control not-disabled"
                                           placeholder="@Loc.Note" />
                                </div>
                            </div>
                        </div>


                        <br />
                        <button type="button" id="newrecord-modal-add" class="btn btn-primary pull-right" onclick="createNewRecord(this)"><i class="fa fa-check m-r-xs"></i><span>@Loc.Add</span></button>
                        <button type="button" data-dismiss="modal" class="btn btn-link pull-right"><i class="fa fa-times m-r-xs text-primary"></i>@Loc.Cancel</button>
                        <button type="button" class="btn btn-link pull-right" onclick="confirmDelete()"><i class="fa fa-trash-alt m-r-xs text-primary"></i>@Loc.Delete</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>