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

@{
    ViewBag.Title = "";
    Layout = null;
}

@using (Html.BeginForm(null, null, FormMethod.Post, new { id = "fixedAssetForm" }))
{
    <div class="clearfix">
        <div class="divided-content-full">
            <div class="col-sm-5">
                <div class="form-horizontal form-md m-t-md">
                    <div class="col-xs-12">
                        <div class="form-group">
                            @Html.LabelFor(model => model.Active, Loc.IsActive, new { @class = "col-md-3 control-label" })
                            <div class="col-md-9">
                                @Html.CheckBoxFor(model => model.Active, new { @class = "form-control js-switch" })
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            @Html.LabelFor(model => model.InventNum, Loc.FaInventNumber, new { @class = "col-md-3 control-label" })
                            <div class="col-md-9">
                                @Html.TextBoxFor(model => model.InventNum,
                                    HtmlAttributesHelper.CreateInputAttributes("form-control", "InventNum", true, Loc.FaInventNumber, false, new { @maxlength = "30", @autocomplete = "off" }))
                                @Html.ValidationMessageFor(model => model.InventNum, "", new { @class = "text-danger", @id = "vl-InventNum" })
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            @Html.LabelFor(model => model.Name, Loc.Name, new { @class = "col-md-3 control-label" })
                            <div class="col-md-9">
                                @Html.TextBoxFor(model => model.Name,
                                    HtmlAttributesHelper.CreateInputAttributes("form-control", "Name", false, Loc.Name, false, new { @maxlength = "30", @autocomplete = "off" }))
                                @Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger", @id = "vl-Name" })
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            @Html.LabelFor(model => model.TypeSpec, Loc.Subtype, new { @class = "col-md-3 control-label" })
                            <div class="col-md-4">
                                @Html.DropDownListFor(model => model.TypeSpec, new SelectList(ViewBag.TypeSpecs != null ? ViewBag.TypeSpecs : new List<string>(), "Value", "Text"),
                                HtmlAttributesHelper.CreateInputAttributes("form-control search-addon custom-select", "TypeSpec", false))
                            </div>
                            @Html.LabelFor(model => model.CarRegNo, Loc.CarRegNoShort, new { @class = "col-md-2 control-label", @id = "lblCarRegNo" })
                            <div class="col-md-3">
                                @Html.TextBoxFor(model => model.CarRegNo,
                                    HtmlAttributesHelper.CreateInputAttributes("form-control", "CarRegNo", false, Loc.CarRegNoShort, false, new { @maxlength = "30", @autocomplete = "off" }))
                                @Html.ValidationMessageFor(model => model.CarRegNo, "", new { @class = "text-danger", @id = "vl-CarRegNo" })
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            @Html.LabelFor(model => model.Quantity, Loc.Quantity, new { @class = "col-md-3 control-label" })
                            <div class="col-md-4">
                                @Html.EditorFor(model => model.Quantity,
                                 new { htmlAttributes = new { @class = "form-control numberInput", @autocomplete = "off", @required = "required", @placeholder = @Loc.Quantity } })
                                @Html.ValidationMessageFor(model => model.Quantity, "", new { @class = "text-danger", @id = "vl-Quantity" })
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            @Html.LabelFor(model => model.DateOfAcq, Loc.DateOfAcq, new { @class = "col-md-3 control-label" })
                            <div class="col-md-4">
                                <div class="input-group">
                                    <span class="input-group-addon"><i class="far fa-calendar alt"></i></span>
                                    @Html.TextBoxFor(model => model.DateOfAcq, Model.DateOfAcq.HasValue ? Model.DateOfAcq.Value.ToString(Loc.DateFormat) : null,
                                           HtmlAttributesHelper.CreateInputAttributes("form-control custom-datepicker", "DateOfAcq", false, Loc.DateOfAcq))
                                </div>
                                @Html.ValidationMessageFor(model => model.DateOfAcq, "", new { @class = "text-danger", @id = "vl-DateOfAcq" })
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            @Html.LabelFor(model => model.DateOfActivation, Loc.DateOfActivation, new { @class = "col-md-3 control-label" })
                            <div class="col-md-4">
                                <div class="input-group">
                                    <span class="input-group-addon"><i class="far fa-calendar alt"></i></span>
                                    @Html.TextBoxFor(model => model.DateOfActivation, Model.DateOfActivation.HasValue ? Model.DateOfActivation.Value.ToString(Loc.DateFormat) : null,
                                           HtmlAttributesHelper.CreateInputAttributes("form-control custom-datepicker", "DateOfActivation", false, Loc.DateOfActivation))
                                </div>
                                @Html.ValidationMessageFor(model => model.DateOfActivation, "", new { @class = "text-danger", @id = "vl-DateOfActivation" })
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            @Html.LabelFor(model => model.AmountAcq, Loc.AmountAcq, new { @class = "col-md-3 control-label" })
                            <div class="col-md-4">
                                @Html.EditorFor(model => model.AmountAcq,
                                 new { htmlAttributes = new { @class = "form-control numberInput", @autocomplete = "off", @required = "required", @placeholder = @Loc.AmountAcq } })
                                @Html.ValidationMessageFor(model => model.AmountAcq, "", new { @class = "text-danger", @id = "vl-AmountAcq" })
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
}

<script>
    $(document).ready(function () {
        updateVisibilities();

        $("#TypeSpec").change(function () {
            updateVisibilities();
        });
    });

    function updateVisibilities() {
        let type = $("#TypeSpec").val();

        let typeC = '@FixedAssetTypeSpec.TypeSpecC';
        let typeD = '@FixedAssetTypeSpec.TypeSpecD';

        let visibility = (type == typeC || type == typeD) ?
            'block' : 'none';

        $('#lblCarRegNo').css("display", visibility);
        $('#CarRegNo').css("display", visibility);
    }
</script>
<script src="~/Scripts/custom/initializers.js"></script>
<script src="~/Scripts/global-script.js"></script>