@model PantheonRA.WebApi.Contracts.TravelOrder
@{ 
    var googleApiKey = string.IsNullOrEmpty(Model.GoogleApiKey) ? "" : Model.GoogleApiKey;
}
@Html.Hidden("Header.ShowDocType", Model.ShowDocType)
@Html.Hidden("PriceKmRate", Model.PriceKmRate)
@Html.Hidden("PrevAcKey", Model.PrevAcKey)
@Html.Hidden("NextAcKey", Model.NextAcKey)
@Html.Hidden("Header.ClassificationId", Model.ClassificationId)
@Html.Hidden("Header.DocTypeDMS", Model.DocTypeDMS)
@Html.Hidden("Header.Subject", Model.Subject)
@Html.Hidden("ItemList", Url.Action("Index", "TravelOrders"))

<div class="row document-head" style="margin-bottom:0px">
    <div class="col-md-2 col-sm-6" id="to-docType-div">
        <div class="form-group">
            @Html.LabelFor(model => model.DocumentType, Loc.DocType, new { @class = "control-label" })
            @Html.ValidationMessageFor(m => m.DocumentType, "", new { @class = "text-danger" })
            <select id="HeaderDocumentType"
                    name="Header.DocumentType"
                    onchange="dropDownChange('HeaderDocumentType', ['HeaderWorker'], [setWorkerDropDown], 'value')"
                    class="form-control select2withAPI"
                    data-url=@Url.Action("GetDropDownValues", "GlobalHelper", new { apiPath = "/DocumentType/lookup-items/documenttypes/S" })
                    data-column-names="@Loc.DocType,@Loc.Name"
                    data-bootstrap-columns="col-md-6,col-md-6"
                    data-search-width="400"
                    data-selector-separator=" - "
                    data-placeholder="@Loc.DocType">
                <option selected value="@Model.DocumentType">@Model.ShowDocType</option>
            </select>
        </div>
    </div>

    <div class="col-md-2 col-sm-6 @(PantheonRA.BackOffice.CurrentUser.HasGranule(PantheonRA.WebApi.Contracts.Enums.Granules.TravelOrderGranule) ? "document-head-disabled-input" : string.Empty)">
        <div class="form-group">
            @Html.LabelFor(model => model.Worker, Loc.EmployeeTR, new { @class = "control-label" })
            @Html.ValidationMessageFor(m => m.Worker, "", new { @class = "text-danger" })
            <select id="HeaderWorker"
                    name="Header.Worker"
                    class="form-control select2withAPI"
                    data-placeholder="@Loc.EmployeeTR"
                    data-column-names="@Loc.Code,@Loc.LastName,@Loc.FirstName,@Loc.Job,@Loc.Department"
                    data-bootstrap-columns="col-md-3,col-md-2,col-md-2,col-md-2,col-md-3"
                    data-search-width="600"
                    data-selector-separator=", "
                    onchange="workerDropDownChange('HeaderWorker', ['HeaderCarRegNo', 'HeaderJob'], [setVehicleDropDown, setJobDropDown], 'filterBy')"
                    data-change-url="@Url.Action("ChangeDropdownsAsync", "TravelOrderAllData")"
                    data-url=@Url.Action("GetDropDownValues", "GlobalHelper", new { apiPath = "/v1/employees/employees-lookupitems" }) >
                <option selected value="@Model.Worker">@Model.WorkerFullName</option>
            </select>
        </div>
    </div>

    <div class="col-md-2 col-sm-6">
        <div class="form-group">
            @Html.LabelFor(model => model.CarRegNo, Loc.Vehicle, new { @class = "control-label" })
            <select id="HeaderCarRegNo"
                    name="Header.CarRegNo"
                    class="form-control select2withAPI"
                    data-placeholder="@Loc.Vehicle"
                    data-column-names="@Loc.CarRegNo,@Loc.Name,@Loc.CompanyVehicle"
                    data-bootstrap-columns="col-md-5,col-md-3,col-md-4"
                    data-search-width="450"
                    data-selector-separator=", "
                    onchange="setMileageByVehicle();"
                    data-change-url="@Url.Action("GetSingleValue", "GlobalHelper", new { apiPath = "/v1/employees/GetById" })"
                    data-url=@Url.Action("GetVehicleItems", "GlobalHelper", new { apiPath = "/v1/vehicles/vehicles-items" })
                    data-pre="@Model.IsCompanyCar.ToString().ToLower()">
                <option selected value="@Model.CarRegNo">@Model.VehicleDisplay</option>
            </select>

        </div>
    </div>

    <div class="col-md-2 col-sm-6">
        <div class="form-group">
            @Html.LabelFor(model => model.Status, Loc.Status, new { @class = "control-label" })

            <select id="HeaderStatus"
                    name="Header.Status"
                    data-placeholder="@Loc.Status"
                    class="form-control select2withAPI"
                    data-url=@Url.Action("GetDropDownValues", "GlobalHelper", new { apiPath = "/v1/travel-orders/statuses-lookupitems" })>
                <option selected value="@Model.Status">@Model.Status</option>
            </select>

        </div>
    </div>

    <div class="col-md-2 col-sm-6 col-xs-6 document-head-disabled-input">
        <div class="form-group">
            @Html.Label("Absence", Loc.Away, new { @class = "control-label" })

            <h4 id="Absence">
                @Model.Abscence
            </h4>
        </div>
    </div>

    <div class="col-md-2 col-sm-6 col-xs-6 document-head-disabled-input">
        <div class="form-group">
            @Html.Hidden("Header.AcKey", Model.AcKey)
            @Html.LabelFor(m => m.AcKey, Loc.AcKey, new { @class = "control-label" })

            <h4 class="control-label @(string.IsNullOrEmpty(Model.AcKeyDisplay) ? "hidden" : string.Empty)" id="AcKeyDisplayContainer">
                <div class="prev-next-key-display">
                    <i class="fa fa-chevron-left" onclick="prevNeighbour('@Model.PrevAcKey')"></i>
                    <span title="@Loc.OpenTravelOrdersList" onclick="goToList('@Model.AcKey', '@Model.Date.ToString("o")')">@Model.AcKeyDisplay</span>
                    <i class="fa fa-chevron-right" onclick="nextNeighbour('@Model.NextAcKey')"></i>
                </div>
            </h4>
        </div>
    </div>
</div>

@Html.Partial("_DistancesCreate", googleApiKey)
