@model PantheonRA.Contracts.DataContracts.CompanyUnitCreateData

@{
    ViewBag.Title = Loc.CompanyUnitDetails;
    Layout = null;
}

<div class="row buttons-ribbon floating-buttons">
    <div class="col-xs-12">
        <a href="@Url.Action("Edit", "CompanyUnits", new { @id = Model.Id })" data-method="initializeCompanyUnitsEdit" class="btn btn-primary pull-right">
            <i class="fa fa-pencil" title="@Loc.EditCompanyUnit"></i><span class="hidden-xs hidden-sm">&nbsp;&nbsp;@Loc.EditCompanyUnit</span>
        </a>
        <a href="@Url.Action("Index", "CompanyUnits", new { @id = Model.Id })" data-method="initializeCompanyUnits" class="btn btn-success pull-right">@Loc.Back</a>
    </div>
</div>

<div>
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox">
                <div class="ibox-content">
                    <div class="tab-title">
                        @Loc.CompanyUnitDetails
                        @if (!Model.IsRegisteredWithFiscalAuthority && PantheonRA.BackOffice.CurrentUser.Localization == PAW.Contracts.Enums.Localization.Code.SI)
                        {
                            <button id="btnRegisterCompanyUnit" type="button" class="btn btn-sm btn-primary btn-outline pull-right">@Loc.RegisterCompanyUnit</button>
                            <button id="btnCheckFiscalServiceConnectivity" type="button" class="btn btn-sm btn-primary btn-outline pull-right m-r-sm">@Loc.CheckServiceAvailability</button>
                        }
                    </div>
                    <div class="row m-b-sm m-t-sm">
                        <div class="col-md-12">

                            @if (!string.IsNullOrEmpty(Model.Id))
                            {
                                <h1>
                                    @Model.Id
                                    <small>
                                        @if (Model.IsMobile)
                                        {
                                            @: @Model.MobileType
                                        }
                                        else
                                        {
                                            @: @Model.ImmovableLocationNameString
                                        }
                                    </small>
                                </h1>
                            }
                            else
                            {
                                <h2>@Html.Raw(string.Format(Loc.PleaseFillTheFormBelow, "<b>" + Loc.CompanyUnitGenitiv.ToLower() + "</b>"))</h2>
                            }

                            @if (!Model.IsRegisteredWithFiscalAuthority)
                            {
                                <div id="alertCompanyUnitRegistered" class="flat alert alert-info alert-fiscal-certificate" style="display:@(Model.IsRegisteredWithFiscalAuthority ? "block" : "none")">
                                    <div class=""><i class="fa fa-check fa-5x"></i></div>
                                    <div>
                                        <p>@Loc.CompanyUnitRegisteredWithFiscalAuthority</p>
                                        <p><small>@String.Format(Loc.CompanyUnitXIsRegisteredWithFiscalAuthorityYouCanIssueVerifiedInvoices, Model.Id)</small></p>
                                    </div>
                                </div>

                                <div class="clearfix"></div>

                                <div id="alertCompanyUnitNotRegistered" class="flat alert alert-warning alert-fiscal-certificate" style="display:@(Model.IsRegisteredWithFiscalAuthority ? "none" : "block")">
                                    <div class=""><i class="fa fa-exclamation fa-5x"></i></div>
                                    <div>
                                        <p class="alert-link">@Loc.RegistrationWithFiscalAuthorityMissing!</p>
                                        <p>@Loc.YouMustRegisterThisCompanyUnitWithFiscalAuthorityBeforeYouCanIssueVerifiedInvoicesFromIt.</p>
                                    </div>
                                </div>

                                <div class="clearfix"></div>
                            }

                            @if (Model.IsMobile)
                            {
                                <div class="row m-t">
                                    <div class="col-md-2 col-xs-4">
                                        <div class="form-group">
                                            <div>
                                                @Html.LabelFor(model => model.IsMobile, Loc.Movable + "?")
                                                <p>@(Model.IsMobile ? Loc.Yes : Loc.No)</p>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-md-4 col-xs-8">
                                        <div class="form-group">
                                            @Html.LabelFor(model => model.MobileType, Loc.MovableType)
                                            <p>@Html.DisplayTextFor(model => model.MobileType)</p>
                                        </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-md-6 col-xs-12">
                                        <div class="form-group">
                                            @Html.LabelFor(model => model.MobileType, Loc.Description)
                                            <p>@Html.DisplayTextFor(model => model.MobileType)</p>
                                        </div>
                                    </div>
                                </div>

                            }
                            else
                            {
                                <div class="row">
                                    <div class="col-md-2 col-sm-10">
                                        <div class="form-group">
                                            @Html.LabelFor(model => model.Street, Loc.Street)
                                            <p>@Html.DisplayTextFor(model => model.Street)</p>
                                        </div>
                                    </div>
                                    <div class="col-md-1 col-sm-2">
                                        <div class="form-group">
                                            @Html.LabelFor(model => model.HouseNumber, Loc.StreetNum)
                                            <p>@Html.DisplayTextFor(model => model.HouseNumber)@Html.DisplayTextFor(model => model.HouseNumberAdditional)</p>
                                        </div>
                                    </div>
                                    <div class="col-md-2 col-sm-8">
                                        <div class="form-group">
                                            @Html.LabelFor(model => model.City, Loc.Town)
                                            <p>@Html.DisplayTextFor(model => model.City)</p>
                                        </div>
                                    </div>
                                    <div class="col-md-1 col-sm-4">
                                        <div class="form-group">
                                            @Html.LabelFor(model => model.Post, Loc.ZipCode)
                                            <p>@Html.DisplayTextFor(model => model.Post)</p>
                                        </div>
                                    </div>
                                    <div class="col-md-2 col-sm-12">
                                        <div class="form-group">
                                            @Html.LabelFor(model => model.Municip, Loc.Region)
                                            <p>@Html.DisplayTextFor(model => model.Municip)</p>
                                        </div>
                                    </div>
                                    <div class="col-md-1 col-sm-4">
                                        <div class="form-group">
                                            @Html.LabelFor(model => model.CadastralNumber, Loc.CadastralNumber)
                                            <p>@Html.DisplayTextFor(model => model.CadastralNumber)</p>
                                        </div>
                                    </div>
                                    <div class="col-md-1 col-sm-4">
                                        <div class="form-group">
                                            @Html.LabelFor(model => model.CadastralBuildingNumber, Loc.BuildingNumber)
                                            <p>@Html.DisplayTextFor(model => model.CadastralBuildingNumber)</p>
                                        </div>
                                    </div>
                                    <div class="col-md-1 col-sm-4">
                                        <div class="form-group">
                                            @Html.LabelFor(model => model.CadastralSectionNumber, Loc.BuildingSectionNumber)
                                            <p>@Html.DisplayTextFor(model => model.CadastralSectionNumber)</p>
                                        </div>
                                    </div>
                                </div>
                            }
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<input type="hidden" id="LocAvailable" value="@Loc.Available" />
<input type="hidden" id="LocUnavailable" value="@Loc.Unavailable" />
<input type="hidden" id="LocFiscalizationServiceIsAvailable" value="@Loc.FiscalizationServiceIsAvailable" />
<input type="hidden" id="LocFiscalizationServiceIsUnavailable" value="@Loc.FiscalizationServiceIsUnavailable" />
<input type="hidden" id="LocErrorHappenedWhileCheckingFiscalServiceConnectivity" value="@Loc.ErrorHappenedWhileCheckingFiscalServiceConnectivity" />
<input type="hidden" id="LocError" value="@Loc.Error" />
<input type="hidden" id="LocErrorHappenedWhileRegisteringCompanyUnit" value="@(Loc.ErrorHappenedWhileRegisteringCompanyUnit + " " + Model.Id)" />
<input type="hidden" id="LocCompanyUnitRegistration" value="@Loc.CompanyUnitRegistration" />
<input type="hidden" id="LocAreYouSureYouWantToRegisterCompanyUnit" value="@string.Format(Loc.AreYouSureYouWantToRegisterCompanyUnit, Model.Id)" />
<input type="hidden" id="LocYes" value="@Loc.Yes" />
<input type="hidden" id="LocNo" value="@Loc.No" />
<input type="hidden" id="LocYouHaveRegisteredThisCompanyUnitWithFiscalAuthority" value="@Loc.YouHaveRegisteredThisCompanyUnitWithFiscalAuthority" />
<input type="hidden" id="LocInvalidCompanyUnitData" value="@Loc.InvalidCompanyUnitData" />
<input type="hidden" id="LocCompanyUnitRegistered" value="@string.Format(Loc.CompanyUnitRegistered, Model.Id)!" />