@using PantheonRA.BackOffice.Enums
@using PantheonRA.WebApi.Contracts
@using PAW.Contracts.Enums
@using PantheonRA.BackOffice
@model PantheonRA.BackOffice.Models.SubjectCreateViewModel

@{
    ViewBag.Title = string.IsNullOrEmpty(Model.SubjectEditData.Id) ? Loc.CreateNewSubject : Loc.EditSubject;
    Layout = null;
    var CanViewData = CurrentUser.IsGDPR || !string.IsNullOrEmpty(Model.SubjectEditData.VAT) || string.IsNullOrEmpty(Model.SubjectEditData.Id);
    var languageCode = CurrentUser.Localizationi18n;
    var isTravelOrder = Model.IsTravelOrder ? "true" : "false";
}

@Html.Hidden("GetGoogleApiKeyUrl", Url.Action("GetGoogleApiKey", "Subjects"))

<div class="modal fade p-none" id="search-dialog" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-100" role="document">
        <div class="modal-content">
            <div class="modal-header model-infinite-body-title clearfix">
                <span class="text-left model-simple-title">@Loc.SelectPartner</span>
                <button type="button" class="close m-l-sm" data-dismiss="modal" aria-label="Close"><i class="fal fa-times m-l-sm"></i></button>
                <button id="search-selection-finish" class="btn btn-primary pull-right"><span><i class="fa fa-check"></i> @Loc.Select</span></button>
            </div>
            <div class="modal-body model-infinite-body ajpes-search-container">
                <div id="search_results">
                    <div class="project-list">
                        <table id="mainGrid" class="list-table simple interactable">
                            <thead>
                                <tr>
                                    <th data-column-id="Selector" data-visible="false"></th>
                                    <th data-column-id="commands" data-formatter="commands" data-width="45px" data-sortable="false"></th>
                                    <th data-column-id="Name" data-width="30%" data-formatter="text">@Loc.Name</th>
                                    <th data-column-id="Street" data-width="15%" data-formatter="text" data-visible="false">@Loc.Street</th>
                                    <th data-column-id="StreetNumber" data-width="6%" data-visible="false">@Loc.StreetNum</th>
                                    <th data-column-id="Town" data-width="10%" data-formatter="text" data-visible="false">@Loc.Town</th>
                                    <th data-column-id="CompleteAddress" data-width="30%" data-formatter="text">@Loc.Address</th>
                                    <th data-column-id="IsVATObligee" data-visible="false" data-visibleInSelection="false">@Loc.IsVATObligee</th>
                                    <th data-column-id="ZipCode" data-visible="false" data-width="10%">@Loc.ZipCode</th>
                                    <th data-column-id="Region" data-visible="false" data-width="10%">@Loc.Region</th>
                                    <th data-column-id="VAT" data-width="10%" data-formatter="text">@Loc.GridVatNumber</th>
                                    <th data-column-id="RegNo" data-width="10%" data-formatter="text">@Loc.RegistrationNumberShort</th>
                                    <th data-column-id="BankAccountNumbers" data-visible="false">@Loc.TRR</th>
                                </tr>
                            </thead>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<input type="hidden" value="@ViewBag.ReturnUrl" id="ReturnUrl" name="ReturnUrl" />
<input type="hidden" value="@DefaultSettingsTypes.DefaultAjpesMaxResults" id="ajpesMaxResult" name="ajpesMaxResult" />
<input type="hidden" id="YesLoc" value="@Loc.Yes" />
<input type="hidden" id="NoLoc" value="@Loc.No" />
<input type="hidden" id="BuyerEnum" value="@SubjectType.Buyer" />
<input type="hidden" id="SupplierEnum" value="@SubjectType.Supplier" />
<input type="hidden" id="CheckStatusUsageUrl" value="@Url.Action("CheckSubjectUsage", "Subjects")" />
<input type="hidden" id="checkIfVATExistsUrl" value="@Url.Action("CheckIfVATExists", "Subjects")" />
<input type="hidden" id="getSubjectWithVATUrl" value="@Url.Action("GetSubjectWithVAT", "Subjects")" />
<input type="hidden" id="SubjectUsedAsBuyer" value="@Loc.SubjectIsUsedAsBuyer" />
<input type="hidden" id="SubjectUsedAsSupplier" value="@Loc.SubjectIsUsedAsSupplier" />
<input type="hidden" id="SubjectUsedAsWarehouse" value="@Loc.SubjectIsUsedAsWarehouse" />
<input type="hidden" id="SubjectSavingPartBankAcc" value="@SubjectSavingPart.BankAccounts" />
<input type="hidden" id="BankAccountAlreadyInUseLoc" value="@Loc.BankAccountAlreadyInUse" />
<input type="hidden" id="SubjectHasSameRegNumberLoc" value="@Loc.SubjectHasSameRegNumber" />
<input type="hidden" id="SubjectWithRegNoAlreadyExistNoDupplicateAllowedLoc" value="@Loc.SubjectWithRegNoAlreadyExistNoDupplicateAllowed" />
<input type="hidden" id="ErrorSavingLoc" value="@Loc.ErrorSaving" />
<input type="hidden" id="SubjectAlreadyInUseLoc" value="@Loc.SubjectAlreadyInUse" />
<input type="hidden" id="ConfirmLoc" value="@Loc.Confirm" />
<input type="hidden" id="SubjectRewriteDataLoc" value="@Loc.RewriteSubjectDataFromAjpes" />
<input type="hidden" id="CurrentLoc" value="@PantheonRA.BackOffice.CurrentUser.Localization.ToString()" />
<input type="hidden" id="SILoc" value="@Localization.Code.SI.ToString()" />
<input type="hidden" id="HRLoc" value="@Localization.Code.HR.ToString()" />
<input type="hidden" id="MELoc" value="@Localization.Code.ME.ToString()" />

@using (Html.BeginForm(null, null, FormMethod.Post, new { id = "subjectForm" }))
{
<div class="clearfix">
    <div class="divided-content-full">
        @Html.HiddenFor(model => model.SubjectEditData.Email)
        @Html.HiddenFor(model => model.SubjectEditData.Phone)
        @Html.HiddenFor(model => model.SubjectEditData.Url)
        @Html.HiddenFor(model => model.SubjectEditData.Fax)
        @Html.HiddenFor(model => model.SubjectEditData.GenerSubjNoLen)
        @Html.HiddenFor(model => model.SubjectEditData.GenerSubjNoFieldLen)
        @Html.HiddenFor(model => model.SubjectEditData.GenerSubjNoConst)
        @Html.HiddenFor(model => model.SubjectEditData.GenerSubjNoField)
        <div class="col-sm-6 column-full-height-border-right">
            <div class="form-horizontal form-md m-t-md">
                <div class="col-xs-12">
                    <h3>@Loc.BasicDataSubject</h3>

                    @if (CanViewData && PantheonRA.BackOffice.CurrentUser.Localization != Localization.Code.MK && PantheonRA.BackOffice.CurrentUser.Localization != Localization.Code.ME)
                        {
                    <div class="row m-b-md">
                        <div class="col-lg-7 col-md-12">
                            <label class="control-label">@Loc.AddSubjectFast</label>
                            <div>
                                <input type="text" value="" id="Search" class="form-control" placeholder="@Loc.PartnersSearch" autocomplete="off" />
                                <a id="ajpesSearch" class="search-icon"><i class="fa fa-search m-t-lg"></i></a>
                            </div>
                        </div>
                        <div class="col-lg-2 col-md-3">
                            @Html.LabelFor(model => model.AjpesSearchMaxResults, Loc.Show, new { @class = "control-label" })
                            @Html.DropDownListFor(model => model.AjpesSearchMaxResults, new List<SelectListItem>
                            {
                               new SelectListItem{ Text="10", Value = "10" },
                               new SelectListItem{ Text="20", Value = "20" },
                               new SelectListItem{ Text="30", Value = "30" },
                               new SelectListItem{ Text="50", Value = "50" },
                            }, HtmlAttributesHelper.CreateInputAttributes("form-control modal-dropdown-small custom-select", "ajpesMaxItems", false, Loc.MaxItemsReturned, false, new { @onchange = "changeAjpesMaxResults()" }))
                        </div>
                        <div class="col-lg-3 col-md-4">
                            @Html.LabelFor(model => model.ForCountry, Loc.ForCountry, new { @class = "control-label text-single-line" })
                            @Html.DropDownListFor(model => model.ForCountry, new List<SelectListItem>
                            {
                               new SelectListItem{ Text="SI", Value = "SI" },
                               new SelectListItem{ Text="BA", Value = "BA" },
                               new SelectListItem{ Text="HR", Value = "HR" },
                               new SelectListItem{ Text="RS", Value = "RS" },
                               new SelectListItem{ Text="MK", Value = "MK" },
                            }, HtmlAttributesHelper.CreateInputAttributes("form-control modal-dropdown-small custom-select", "ForCountry", false, Loc.ForCountry, false))
                        </div>
                    </div>
                        }

                    <div class="form-group">
                        @Html.LabelFor(model => model.SubjectEditData.IsActive, Loc.IsActive, new { @class = "col-md-2 control-label" })
                        <div class="col-md-10">
                            @Html.CheckBoxFor(model => model.SubjectEditData.IsActive, new { @id = "IsActive", @class = "form-control js-switch" })
                        </div>
                    </div>
                    <div class="form-group">
                        @Html.LabelFor(model => model.SubjectEditData.Id, Loc.Code, new { @class = "col-md-2 control-label" })
                        <div class="col-md-10">
                            @Html.HiddenFor(model => model.IsEdit)
                            @Html.TextBoxFor(model => model.SubjectEditData.Id,
                                HtmlAttributesHelper.CreateInputAttributes("form-control", "SubjectEditData_Id", Model.IsEdit ? true : false, Loc.Code, false, new { @maxlength = "30", @autocomplete = "off" }))
                            @Html.ValidationMessageFor(model => model.SubjectEditData.Id, "", new { @class = "text-danger", @id = "SubjectEditData_Id-validation" })
                        </div>
                    </div>
                    <div class="form-group">
                        @Html.LabelFor(model => model.SubjectEditData.Name, Loc.Name, new { @class = "col-md-2 control-label" })
                        <div class="col-md-10">
                            @GDPRInput(CanViewData, "SubjectEditData_Name", Model.SubjectEditData.Name, Loc.Name, null, null, "255")
                        </div>
                    </div>
                    <div class="form-group">
                        @Html.LabelFor(model => model.SubjectEditData.Address, Loc.Address, new { @class = "col-md-2 control-label" })
                        <div class="col-md-10" id="subjects-google-search">
                            @GDPRInput(CanViewData, "SubjectEditData_Address", Model.SubjectEditData.Address, Loc.Address)
                        </div>
                        <div class="col-md-10" id="subjects-plain-search" style="display: none">
                            @GDPRInput(CanViewData, "SubjectEditData_Address", Model.SubjectEditData.Address, Loc.Address)
                        </div>
                    </div>
                    <div class="form-group">
                        @Html.LabelFor(model => model.SubjectEditData.Town, Loc.Post, new { @class = "col-md-2 control-label" })
                        <div class="col-md-10">
                            @GDPRInput(CanViewData, "SubjectEditData_ZipCode", Model.SubjectEditData.ZipCode, Loc.Post, "form-control typeahead_3 typeahead_medium", Url.Action("SearchPosts", "Post"))
                        </div>
                    </div>
                    <div class="form-group">
                        @Html.LabelFor(model => model.SubjectEditData.SelectedCountryId, Loc.Country, new { @class = "col-md-2 control-label" })
                        <div class="col-md-10">
                            @Html.HiddenFor(model => model.SubjectEditData.Country)
                            @if (CanViewData)
                                {
                            <select id="SubjectEditData_SelectedCountryId" name="@Html.NameFor(model => model.SubjectEditData.SelectedCountryId)" class="form-control custom-select">
                                <option></option>
                                @if (ViewBag.Countries != null)
                                        {
                                            foreach (var item in ViewBag.Countries)
                                            {
                                <option value="@item.ISOCode" data-country="@item.Country" @(Model.SubjectEditData.SelectedCountryId == item.Country ? "selected" : string.Empty)>
                                    @(item.Country)
                                </option>
                                            }
                                        }
                            </select>
                            @Html.ValidationMessageFor(model => model.SubjectEditData.SelectedCountryId, "", new { @class = "text-danger", @id = "SubjectEditData_SelectedCountryId-validation" })
                                }
                                else
                                {
                            @Html.Password("SubjectEditData.SelectedCountryId", Model.Countries.SingleOrDefault(s => s.Country == Model.SubjectEditData.SelectedCountryId.ToString()).Country, new { @id = "SelectedCountryId", @class = "form-control", @readonly = "" })
                                }
                        </div>
                    </div>
                    <div class="form-group">
                        @Html.LabelFor(model => model.SubjectEditData.VAT, Loc.GridVatNumber, new { @class = "col-md-2 control-label" })
                        <div class="col-md-10">
                            <div class="row">
                                <div class="col-lg-3 col-xs-4">
                                    @Html.DropDownListFor(model => model.SubjectEditData.VATPrefix, (SelectList)ViewBag.Prefixes, "", new { @class = "form-control prefix-input-small", @id = "VATPrefix" })
                                </div>
                                <div class="col-lg-9 col-xs-8">
                                    @GDPRInput(CanViewData, "SubjectEditData_VAT", Model.SubjectEditData.VAT, Loc.GridVatNumber, null, null, null)
                                </div>
                            </div>
                        </div>
                    </div>
                    @if (PantheonRA.BackOffice.CurrentUser.Localization == Localization.Code.HR)
                        {
                    <div class="form-group">
                        @Html.LabelFor(model => model.SubjectEditData.Pin, Loc.Oib, new { @class = "col-md-2 control-label" })
                        <div class="col-md-3">
                            @GDPRInput(CanViewData, "SubjectEditData_PinPrefix", Model.SubjectEditData.PinPrefix, Loc.Prefix)
                        </div>
                        <div class="col-md-7 padding-left-none">
                            @GDPRInput(CanViewData, "SubjectEditData_Pin", Model.SubjectEditData.Pin, Loc.Oib)
                        </div>
                    </div>
                        }
                        else
                        {
                    @Html.HiddenFor(model => model.SubjectEditData.Pin)
                    @Html.HiddenFor(model => model.SubjectEditData.PinPrefix)
                        }

                    <div class="form-group">
                        @Html.LabelFor(model => model.SubjectEditData.RegNo, Loc.RegistrationNumberShort, new { @class = "col-md-2 control-label" })
                        <div class="col-md-10">
                            @GDPRInput(CanViewData, "SubjectEditData_RegNo", Model.SubjectEditData.RegNo, Loc.RegistrationNumberShort)
                        </div>
                    </div>

                    @if (PantheonRA.BackOffice.CurrentUser.Localization == Localization.Code.RS)
                        {
                    <div class="form-group">
                        @Html.LabelFor(model => model.SubjectEditData.BudgedUser, Loc.BudgedUser, new { @class = "col-md-2 control-label" })
                        <div class="col-md-4">
                            @Html.DropDownListFor(model => model.SubjectEditData.BudgedUser, new List<SelectListItem>
                            {
                               new SelectListItem{ Text=string.Empty, Value = "0" },
                               new SelectListItem{ Text=Loc.Direct, Value = "1" },
                               new SelectListItem{ Text=Loc.Indirect, Value = "2" },
                            }, HtmlAttributesHelper.CreateInputAttributes("form-control custom-select", "SubjectEditData_BudgedUser", false))
                        </div>
                        <div id="jbkjsContainer" @(string.IsNullOrEmpty(Model.SubjectEditData.BudgedUser) || Model.SubjectEditData.BudgedUser == "0" ? "hidden" : "")>
                            @Html.LabelFor(model => model.SubjectEditData.JBKJS, Loc.JBKJS, new { @class = "col-md-2 control-label" })
                            <div class="col-md-4 padding-left-none">
                                @GDPRInput(CanViewData, "SubjectEditData_JBKJS", Model.SubjectEditData.JBKJS, Loc.JBKJS, null, null, "5")
                            </div>
                        </div>
                    </div>
                        }

                    <div class="form-group">
                        @Html.LabelFor(model => model.SubjectEditData.BankAccountNumbers, Loc.TRR, new { @class = "col-md-2 control-label", @title = Loc.TRR })
                        <div class="col-md-10">
                            @GDPRInput(CanViewData, "SubjectEditData_BankAccountNumbers", "", Loc.TRR, "form-control addable-input", null, null, true)
                            <div class="addable-button">
                                <button type="button" title="@Loc.AddOrEditInvoice" class="btn btn-outline btn-primary createNewButton" onclick="openSubjectTrrModal()">
                                    <i class="fas fa-pencil-alt"></i>
                                </button>
                            </div>
                        </div>
                    </div>

                    @if (PantheonRA.BackOffice.CurrentUser.Localization == Localization.Code.RS)
                        {
                    <div class="form-group">
                        @Html.LabelFor(model => model.SubjectEditData.RotationNumber, Loc.RotationNumber, new { @class = "col-md-2 control-label", @title = Loc.RotationNumber })
                        <div class="col-md-10">
                            @GDPRInput(CanViewData, "SubjectEditData_RotationNumber", Model.SubjectEditData.RotationNumber, Loc.RotationNumber)
                        </div>
                    </div>
                        }

                    <div class="form-group">
                        @Html.LabelFor(model => model.SubjectEditData.XmlDocType, Loc.SubjectXmlDocType, new { @class = "col-md-2 control-label", @title = Loc.SubjectXmlDocType })
                        <div class="col-md-10">
                            <select id="SubjectEditData.XmlDocType"
                                    name="SubjectEditData.XmlDocType"
                                    data-placeholder="@Loc.SubjectXmlDocType"
                                    class="form-control select2withAPI"
                                    data-column-names="@Loc.Code,@Loc.Name"
                                    data-selector-separator=" - "
                                    data-bootstrap-columns="col-md-3,col-md-9"
                                    data-url=@Url.Action("GetXmlDocTypes", "Subjects")>
                                <option selected="selected" value="@Model.SubjectEditData.XmlDocType">@Model.SubjectEditData.XmlDocTypeText</option>
                            </select>
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-md-12">
                            @Html.ValidationSummary(true)
                        </div>
                    </div>

                    <h3>@Loc.ContactsData</h3>
                    <div class="subject-contacts-table border-top-divider">
                        <table id="subject-contacts" class="table">
                            <thead>
                                <tr>
                                    <th width="45%">@Loc.ContactType</th>
                                    <th width="45%">@Loc.ContactData</th>
                                    <th width="10%"></th>
                                </tr>
                            </thead>
                            <tbody id="subject-contacts-tbody">
                                <tr>
                                    <td class="no-padding">
                                        @Html.DropDownList("SubjectContactType", new SelectList(ViewBag.SubjectContacts != null ? ViewBag.SubjectContacts : new List<string>(), "Id", "Name"), Loc.Select,
                                        HtmlAttributesHelper.CreateInputAttributes("form-control custom-select", "SubjectContactType", false))
                                    </td>
                                    <td class="no-padding">
                                        <input class="form-control" id="subjectContactValue" />
                                    </td>
                                    <td class="no-padding">
                                        <button type="button" class="btn btn-primary" onclick="AddSubjectContactData()"><i class="fa fa-plus"></i></button>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>

                    <div class="form-group margin-top-10">
                        <label class="col-md-2 control-label">@Loc.Note</label>
                        <div class="col-md-10">
                            @Html.TextAreaFor(model => model.SubjectEditData.Note, new { @class = "form-control", rows = 3 })
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-sm-6">
            <div class="form-horizontal form-md m-t-md">
                <div class="col-xs-12">
                    <h3>@Loc.TypeOfSubject</h3>

                    <div class="form-group">
                        @Html.LabelFor(model => model.SubjectEditData.IsBuyer, Loc.Buyer, new { @class = "col-md-3 control-label" })
                        <div class="col-md-9 m-t-xs">
                            @Html.CheckBoxFor(model => model.SubjectEditData.IsBuyer, new { @id = "IsBuyer", @class = "form-control js-switch" })
                        </div>
                    </div>
                    <div id="buyerData">
                        <div class="form-group">
                            @Html.LabelFor(model => model.SubjectEditData.WayOfSale, Loc.WayOfSelling, new { @class = "col-md-3 control-label", @title = Loc.WayOfSelling })
                            <div class="col-md-9">
                                <input id="Current_SubjectEditData_WayOfSale" value="@Model.SubjectEditData.WayOfSale" hidden />
                                @if (PantheonRA.BackOffice.CurrentUser.Localization == Localization.Code.BA)
                                    {
                                @Html.DropDownListFor(model => model.SubjectEditData.WayOfSale, new List<SelectListItem>
                                 {
                                    new SelectListItem{ Text=Loc.SubjTaxPayer, Value = WayOfSale.IsTaxComitted },
                                    new SelectListItem{ Text=Loc.ExportSale, Value = WayOfSale.ExportSale },
                                    new SelectListItem{ Text=Loc.ExportSaleEU, Value = WayOfSale.ExportSaleEU },
                                    new SelectListItem{ Text=Loc.FinalBuyer, Value = WayOfSale.FinalBuyer },
                                    new SelectListItem{ Text=Loc.Nonresident, Value = WayOfSale.Nonresident },
                                    new SelectListItem{ Text=Loc.Other, Value = WayOfSale.Other },
                                 }, HtmlAttributesHelper.CreateInputAttributes("form-control custom-select", "SubjectEditData_WayOfSale", false, Loc.WayOfSelling))
                                @Html.ValidationMessageFor(model => model.SubjectEditData.WayOfSale, "", new { @class = "text-danger", @id = "SubjectEditData_WayOfSale-validation" })
                                    }
                                    else if (PantheonRA.BackOffice.CurrentUser.Localization == Localization.Code.ME)
                                    {
                                @Html.DropDownListFor(model => model.SubjectEditData.WayOfSale, new List<SelectListItem>
                                 {
                                    new SelectListItem{ Text=Loc.SubjTaxPayer, Value = WayOfSale.IsTaxComitted },
                                    new SelectListItem{ Text=Loc.FinalBuyer, Value = WayOfSale.FinalBuyer },
                                    new SelectListItem{ Text=Loc.ExportSale, Value = WayOfSale.ExportSale },
                                 }, HtmlAttributesHelper.CreateInputAttributes("form-control custom-select", "SubjectEditData_WayOfSale", false, Loc.WayOfSelling))
                                @Html.ValidationMessageFor(model => model.SubjectEditData.WayOfSale, "", new { @class = "text-danger", @id = "SubjectEditData_WayOfSale-validation" })
                                    }
                                    else if (PantheonRA.BackOffice.CurrentUser.Localization == Localization.Code.RS
                                        || PantheonRA.BackOffice.CurrentUser.Localization == Localization.Code.MK)
                                    {
                                @Html.DropDownListFor(model => model.SubjectEditData.WayOfSale, new List<SelectListItem>
                                 {
                                    new SelectListItem{ Text=Loc.IsTaxCommitedShort, Value = WayOfSale.IsTaxComitted },
                                    new SelectListItem{ Text=Loc.ExportSale, Value = WayOfSale.ExportSale },
                                    new SelectListItem{ Text=Loc.FinalBuyer, Value = WayOfSale.FinalBuyer },
                                    new SelectListItem{ Text=Loc.WayOfSaleDiplomaticConsulate, Value = WayOfSale.DiplomaticConsulate },
                                 }, HtmlAttributesHelper.CreateInputAttributes("form-control custom-select", "SubjectEditData_WayOfSale", false, Loc.WayOfSelling))
                                @Html.ValidationMessageFor(model => model.SubjectEditData.WayOfSale, "", new { @class = "text-danger", @id = "SubjectEditData_WayOfSale-validation" })
                                    }
                                    else if (PantheonRA.BackOffice.CurrentUser.Localization == Localization.Code.HR)
                                    {
                                @Html.DropDownListFor(model => model.SubjectEditData.WayOfSale, new List<SelectListItem>
                                 {
                                    new SelectListItem{ Text=Loc.WayOfSaleBuyerR1, Value = WayOfSale.IsTaxComitted },
                                    new SelectListItem{ Text=Loc.ExportSale, Value = WayOfSale.ExportSale },
                                    new SelectListItem{ Text=Loc.ExportSaleEU, Value = WayOfSale.ExportSaleEU },
                                    new SelectListItem{ Text=Loc.FinalBuyer, Value = WayOfSale.FinalBuyer },
                                    new SelectListItem{ Text=Loc.TaxExempt, Value = WayOfSale.Nonresident },
                                    new SelectListItem{ Text=Loc.Other, Value = WayOfSale.Other },
                                 }, HtmlAttributesHelper.CreateInputAttributes("form-control custom-select", "SubjectEditData_WayOfSale", false, Loc.WayOfSelling))
                                @Html.ValidationMessageFor(model => model.SubjectEditData.WayOfSale, "", new { @class = "text-danger", @id = "SubjectEditData_WayOfSale-validation" })
                                    }
                                    else
                                    {
                                @Html.DropDownListFor(model => model.SubjectEditData.WayOfSale, new List<SelectListItem>
                                 {
                                    new SelectListItem{ Text=Loc.IsTaxCommitedShort, Value = WayOfSale.IsTaxComitted },
                                    new SelectListItem{ Text=Loc.FinalBuyer, Value = WayOfSale.FinalBuyer },
                                    new SelectListItem{ Text=Loc.ExportSale, Value = WayOfSale.ExportSale },
                                    new SelectListItem{ Text=Loc.ExportSaleEU, Value = WayOfSale.ExportSaleEU }
                                 }, HtmlAttributesHelper.CreateInputAttributes("form-control custom-select", "SubjectEditData_WayOfSale", false, Loc.WayOfSelling))
                                @Html.ValidationMessageFor(model => model.SubjectEditData.WayOfSale, "", new { @class = "text-danger", @id = "SubjectEditData_WayOfSale-validation" })
                                    }
                            </div>
                        </div>
                        <div class="form-group">
                            @Html.LabelFor(model => model.SubjectEditData.PaymentMethodId, Loc.DefaultPaymentMethod, new { @class = "col-md-3 control-label", @title = Loc.DefaultPaymentMethod })
                            <div class="col-md-9">
                                <select id="@Html.IdFor(model => model.SubjectEditData.PaymentMethodId)" name="@Html.NameFor(model => model.SubjectEditData.PaymentMethodId)" class="form-control custom-select">
                                    <option></option>
                                    @if (ViewBag.PaymentTypes != null)
                                        {
                                            foreach (var item in ViewBag.PaymentTypes)
                                            {
                                    <option value="@item.PaymentMethod" @(Model.SubjectEditData.PaymentMethodId == item.PaymentMethod ? "selected" : string.Empty)>
                                        @(item.PaymentMethod) - @(string.IsNullOrEmpty(item.FiscalGroup) ? item.Name : item.FiscalGroup + " - " + item.Name)
                                    </option>
                                            }
                                        }
                                </select>
                                @Html.ValidationMessageFor(model => model.SubjectEditData.PaymentMethodId, "", new { @class = "text-danger", @id = "SubjectEditData_PaymentMethodId-validation" })
                            </div>
                        </div>
                        <div class="form-group">
                            @Html.LabelFor(model => model.SubjectEditData.DaysForPayment, Loc.DateDue, new { @class = "col-md-3 control-label", @title = Loc.DateDue })
                            <div class="col-md-9">
                                @GDPRInput(CanViewData, "SubjectEditData.DaysForPayment", Model.SubjectEditData.DaysForPayment.ToString(), Loc.DateDue)
                            </div>
                        </div>
                        <div class="form-group">
                            @Html.LabelFor(model => model.SubjectEditData.PriceRate, Loc.PriceRate, new { @class = "col-md-3 control-label", @title = Loc.PriceRate })
                            <div class="col-md-9">
                                @Html.DropDownListFor(model => model.SubjectEditData.PriceRate, new List<SelectListItem>
                                 {
                                    new SelectListItem{ Text = Model.Price1, Value = PriceRate.SalePrice },
                                    new SelectListItem{ Text = Model.Price2, Value = PriceRate.WholesalePrice1 },
                                    new SelectListItem{ Text = Model.Price3, Value = PriceRate.WholesalePrice2 },
                                 }, HtmlAttributesHelper.CreateInputAttributes("form-control custom-select", "SubjectEditData_PriceRate", false, Loc.PriceRate))
                                @Html.ValidationMessageFor(model => model.SubjectEditData.PriceRate, "", new { @class = "text-danger", @id = "SubjectEditData_PriceRate-validation" })
                            </div>
                        </div>
                        <div class="form-group">
                            @Html.LabelFor(model => model.SubjectEditData.Rabate, Loc.FixedMargin, new { @class = "col-md-3 control-label", @title = Loc.FixedMargin })
                            <div class="col-md-9">
                                @GDPRInput(CanViewData, "SubjectEditData.Rabate", Model.SubjectEditData.Rabate.ToString(), Loc.MarginDescription)
                            </div>
                        </div>
                        <div class="form-group">
                            @Html.LabelFor(model => model.SubjectEditData.Currency, Loc.Currency, new { @class = "col-md-3 control-label", @title = Loc.Currency })
                            <div class="col-md-9">
                                @Html.DropDownListFor(model => model.SubjectEditData.Currency, new SelectList(ViewBag.CurrencyTypes, "Value", "Text", "EUR"), Loc.Currency,
                                    HtmlAttributesHelper.CreateInputAttributes("form-control custom-select", "SubjectEditData_Currency", false))
                                @Html.ValidationMessageFor(model => model.SubjectEditData.Currency, "", new { @class = "text-danger", @id = "SubjectEditData_Currency-validation" })
                            </div>
                        </div>
                        <div class="form-group">
                            @Html.LabelFor(model => model.SubjectEditData.IdentList, Loc.OrderIdents, new { @class = "col-md-3 control-label" })
                            <div class="col-md-9 m-t-xs">
                                <select id="IdentList"
                                        name="IdentList"
                                        data-placeholder="@Loc.Ident"
                                        data-search-width="150"
                                        data-column-names="@Loc.Id,@Loc.Name"
                                        data-bootstrap-columns="col-md-4,col-md-8"
                                        class="form-control select2withAPI select2-remove-float-right"
                                        multiple=""
                                        token-separators=";"
                                        data-url=@Url.Action("GetIdents", "SetItem") ?valueWithKey=true>
                                    @if (!string.IsNullOrEmpty(Model.SubjectEditData.IdentList))
                                        {
                                            foreach (var ident in Model.SubjectEditData.IdentList.Split(';'))
                                            {
                                    <option value="@ident" selected="selected">@ident</option>
                                            }
                                        }
                                </select>
                                @Html.ValidationMessageFor(model => model.SubjectEditData.IdentList, "", new { @class = "text-danger", @id = "SubjectEditData_IdentList-validation" })
                            </div>
                        </div>
                        <div class="form-group">
                            @Html.LabelFor(model => model.SubjectEditData.Consignee, Loc.Recipient, new { @class = "col-md-3 control-label" })
                            <div class="col-md-9 m-t-xs">
                                <select id="Consignee"
                                        name="Consignee"
                                        data-placeholder="@Loc.Recipient"
                                        data-search-width="150"
                                        data-column-names="@Loc.Id,@Loc.Name"
                                        data-bootstrap-columns="col-md-4,col-md-8"
                                        class="form-control select2withAPI select2-remove-float-right"
                                        multiple=""
                                        token-separators=";"
                                        data-url=@Url.Action("GetSubjects", "Subjects") ?valueWithKey=true>
                                    @if (!string.IsNullOrEmpty(Model.SubjectEditData.Consignee))
                                        {
                                            foreach (var consignee in Model.SubjectEditData.Consignee.Split(';'))
                                            {
                                    <option value="@consignee" selected="selected">@consignee</option>
                                            }
                                        }
                                </select>
                                @Html.ValidationMessageFor(model => model.SubjectEditData.Consignee, "", new { @class = "text-danger", @id = "SubjectEditData_Consignee-validation" })
                            </div>
                        </div>
                        <div class="form-group">
                            @Html.LabelFor(model => model.SubjectEditData.WarehouseStockNotInQty, Loc.ShowStockWithYesNo, new { @class = "col-md-3 control-label", @title = Loc.ShowStockWithYesNo })
                            <div class="col-md-9 m-t-xs">
                                @Html.CheckBoxFor(model => model.SubjectEditData.WarehouseStockNotInQty, new { @id = "WarehouseStockNotInQty", @class = "form-control js-switch" })
                            </div>
                        </div>
                    </div>

                    <div class="form-group m-t-md">
                        @Html.LabelFor(model => model.SubjectEditData.IsSupplier, Loc.Supplier, new { @class = "col-md-3 control-label", @title = Loc.Supplier })
                        <div class="col-md-9 m-t-xs">
                            @Html.CheckBoxFor(model => model.SubjectEditData.IsSupplier, new { @id = "IsSupplier", @class = "form-control js-switch" })
                        </div>
                        <div class="col-md-offset-3 col-md-9">
                            @Html.ValidationMessageFor(model => model.SubjectEditData.IsSupplier, "", new { @class = "text-danger", @id = "SubjectEditData_IsSupplier-validation" })
                        </div>
                    </div>
                    <div id="supplierData">
                        <div class="form-group">
                            @Html.LabelFor(model => model.SubjectEditData.WayOfSaleSupplier, Loc.MethodOfProcurement, new { @class = "col-md-3 control-label", @title = Loc.MethodOfProcurement })
                            <div class="col-md-4" id="SubjectWayOfSaleSupplierContainer">
                                <input id="Current_WayOfSaleSupplier" value="@Model.SubjectEditData.WayOfSaleSupplier" hidden />
                                @if (PantheonRA.BackOffice.CurrentUser.Localization == Localization.Code.BA)
                                    {
                                @Html.DropDownListFor(model => model.SubjectEditData.WayOfSaleSupplier, new List<SelectListItem>
                                {
                                    new SelectListItem{ Text=Loc.WayOfSaleR1, Value = WayOfSale.R1 },
                                    new SelectListItem{ Text=Loc.WayOfSaleR2, Value = WayOfSale.R2 },
                                    new SelectListItem{ Text=Loc.DomesticOtherPersons, Value = WayOfSale.OtherNotTaxComitted },
                                    new SelectListItem{ Text=Loc.Import, Value = WayOfSale.Import },
                                    new SelectListItem{ Text=Loc.ImportEU, Value = WayOfSale.ImportEU },
                                    new SelectListItem{ Text=Loc.Nonresident, Value = WayOfSale.Nonresident },
                                }, HtmlAttributesHelper.CreateInputAttributes("form-control custom-select", "WayOfSaleSupplier", false, Loc.MethodOfProcurement))
                                    }
                                    else if (PantheonRA.BackOffice.CurrentUser.Localization == Localization.Code.HR)
                                    {
                                @Html.DropDownListFor(model => model.SubjectEditData.WayOfSaleSupplier, new List<SelectListItem>
                                {
                                    new SelectListItem{ Text=Loc.WayOfSaleR1, Value = WayOfSale.R1 },
                                    new SelectListItem{ Text=Loc.WayOfSaleR2, Value = WayOfSale.R2 },
                                    new SelectListItem{ Text=Loc.OtherPersonsNotTaxpayers, Value = WayOfSale.OtherNotTaxComitted },
                                    new SelectListItem{ Text=Loc.Import, Value = WayOfSale.Import },
                                    new SelectListItem{ Text=Loc.ImportEU, Value = WayOfSale.ImportEU },
                                    new SelectListItem{ Text=Loc.Nonresident, Value = WayOfSale.Nonresident },
                                }, HtmlAttributesHelper.CreateInputAttributes("form-control custom-select", "WayOfSaleSupplier", false, Loc.MethodOfProcurement))
                                    }
                                    else if (PantheonRA.BackOffice.CurrentUser.Localization == Localization.Code.SI)
                                    {
                                @Html.DropDownListFor(model => model.SubjectEditData.WayOfSaleSupplier, new List<SelectListItem>
                                {
                                    new SelectListItem{ Text=Loc.IsTaxCommitedShort, Value = WayOfSale.DomesticTaxpayers },
                                    new SelectListItem{ Text=Loc.OtherPersonsNotTaxpayers, Value = WayOfSale.OtherNotTaxComitted },
                                    new SelectListItem{ Text=Loc.Import, Value = WayOfSale.Import },
                                    new SelectListItem{ Text=Loc.ImportEU, Value = WayOfSale.ImportEU },
                                    new SelectListItem{ Text=Loc.Nonresident, Value = WayOfSale.Nonresident },
                                    new SelectListItem{ Text=Loc.Flatrate, Value = WayOfSale.Flatrate },
                                }, HtmlAttributesHelper.CreateInputAttributes("form-control custom-select", "WayOfSaleSupplier", false, Loc.MethodOfProcurement))
                                    }
                                    else if (PantheonRA.BackOffice.CurrentUser.Localization == Localization.Code.ME)
                                    {
                                @Html.DropDownListFor(model => model.SubjectEditData.WayOfSaleSupplier, new List<SelectListItem>
                                {
                                    new SelectListItem{ Text=Loc.DomesticTaxpayers, Value = WayOfSale.DomesticTaxpayers },
                                    new SelectListItem{ Text=Loc.OtherPersonsNotTaxpayers, Value = WayOfSale.OtherNotTaxComitted },
                                    new SelectListItem{ Text=Loc.Import, Value = WayOfSale.Import },
                                    new SelectListItem{ Text=Loc.Nonresident, Value = WayOfSale.Nonresident }
                                }, HtmlAttributesHelper.CreateInputAttributes("form-control custom-select", "WayOfSaleSupplier", false, Loc.MethodOfProcurement))
                                    }
                                    else
                                    {
                                @Html.DropDownListFor(model => model.SubjectEditData.WayOfSaleSupplier, new List<SelectListItem>
                                {
                                    new SelectListItem{ Text=Loc.DomesticTaxpayers, Value = WayOfSale.DomesticTaxpayers },
                                    new SelectListItem{ Text=Loc.OtherPersonsNotTaxpayers, Value = WayOfSale.OtherNotTaxComitted },
                                    new SelectListItem{ Text=Loc.Import, Value = WayOfSale.Import },
                                    new SelectListItem{ Text=Loc.Nonresident, Value = WayOfSale.Nonresident },
                                    new SelectListItem{ Text=Loc.Flatrate, Value = WayOfSale.Flatrate },
                                }, HtmlAttributesHelper.CreateInputAttributes("form-control custom-select", "WayOfSaleSupplier", false, Loc.MethodOfProcurement))
                                    }
                                @Html.ValidationMessageFor(model => model.SubjectEditData.WayOfSale, "", new { @class = "text-danger", @id = "SubjectEditData_WayOfSaleSupplier-validation" })
                            </div>
                            <div id="SubjectLumpContractsContainer" class="col-md-6">
                                @GDPRInput(CanViewData, "SubjectEditData_PermitLumpCompen", Model.SubjectEditData.PermitLumpCompen, Loc.CompensationAllowanceNumber, "form-control addable-input", null, null, true)
                                <div class="addable-button">
                                    <button type="button" title="@Loc.Add" class="btn btn-outline btn-primary createNewButton" onclick="openSubjectLumpContractsModal()">
                                        <i class="fas fa-pencil-alt"></i>
                                    </button>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            @Html.LabelFor(model => model.SubjectEditData.PaymentMethodIdSupplier, Loc.DefaultPaymentMethod, new { @class = "col-md-3 control-label", @title = Loc.DefaultPaymentMethod })
                            <div class="col-md-9">
                                <select id="@Html.IdFor(model => model.SubjectEditData.PaymentMethodIdSupplier)" name="@Html.NameFor(model => model.SubjectEditData.PaymentMethodIdSupplier)" class="form-control custom-select">
                                    <option></option>
                                    @if (ViewBag.PaymentTypes != null)
                                        {
                                            foreach (var item in ViewBag.PaymentTypes)
                                            {
                                    <option value="@item.PaymentMethod" @(Model.SubjectEditData.PaymentMethodIdSupplier == item.PaymentMethod ? "selected" : string.Empty)>
                                        @(item.PaymentMethod) - @(string.IsNullOrEmpty(item.FiscalGroup) ? item.Name : item.FiscalGroup + " - " + item.Name)
                                    </option>
                                            }
                                        }
                                </select>
                                @Html.ValidationMessageFor(model => model.SubjectEditData.PaymentMethodIdSupplier, "", new { @class = "text-danger", @id = "SubjectEditData_PaymentMethodIdSupplier-validation" })
                            </div>
                        </div>
                        <div class="form-group">
                            @Html.LabelFor(model => model.SubjectEditData.DaysForPaymentSupplier, Loc.DateDue, new { @class = "col-md-3 control-label", @title = Loc.DateDue })
                            <div class="col-md-9">
                                @GDPRInput(CanViewData, "SubjectEditData.DaysForPaymentSupplier", Model.SubjectEditData.DaysForPaymentSupplier.ToString(), Loc.DateDue)
                            </div>
                        </div>
                        <div class="form-group">
                            @Html.LabelFor(model => model.SubjectEditData.RabateSupplier, Loc.FixedMargin, new { @class = "col-md-3 control-label", @title = Loc.FixedMargin })
                            <div class="col-md-9">
                                @GDPRInput(CanViewData, "SubjectEditData.RabateSupplier", Model.SubjectEditData.RabateSupplier.ToString(), Loc.MarginDescription)
                            </div>
                        </div>
                        <div class="form-group">
                            @Html.LabelFor(model => model.SubjectEditData.SuppCurrency, Loc.Currency, new { @class = "col-md-3 control-label" })
                            <div class="col-md-9">
                                @Html.DropDownListFor(model => model.SubjectEditData.SuppCurrency, new SelectList(ViewBag.CurrencyTypes, "Value", "Text", "EUR"), Loc.Currency,
                                    HtmlAttributesHelper.CreateInputAttributes("form-control custom-select", "SubjectEditData_SuppCurrency", false))
                                @Html.ValidationMessageFor(model => model.SubjectEditData.SuppCurrency, "", new { @class = "text-danger", @id = "SubjectEditData_SuppCurrency-validation" })
                            </div>
                        </div>
                    </div>

                    <div class="form-group m-t-md">
                        @Html.LabelFor(model => model.SubjectEditData.IsWarehouse, Loc.Warehouse, new { @class = "col-md-3 control-label", @title = Loc.Warehouse })
                        <div class="col-md-9 m-t-xs">
                            @Html.CheckBoxFor(model => model.SubjectEditData.IsWarehouse, new { @id = "IsWarehouse", @class = "form-control js-switch" })
                        </div>
                    </div>
                    <div id="warehouseData">
                        <div class="form-group">
                            @Html.LabelFor(model => model.SubjectEditData.StockManage, Loc.StockManage, new { @class = "col-md-3 control-label", @title = Loc.StockManage })
                            <div class="col-md-9">
                                @Html.CheckBoxFor(model => model.SubjectEditData.StockManage, new { @id = "StockManage", @class = "form-control js-switch" })
                            </div>
                        </div>
                        <div class="form-group">
                            @Html.LabelFor(model => model.SubjectEditData.AllowStockInMinus, Loc.AllowStockInMinus, new { @class = "col-md-3 control-label", @title = Loc.AllowStockInMinus })
                            <div class="col-md-9">
                                @Html.CheckBoxFor(model => model.SubjectEditData.AllowStockInMinus, new { @id = "StockManage", @class = "form-control js-switch" })
                            </div>
                        </div>
                        <div class="form-group">
                            @Html.LabelFor(model => model.SubjectEditData.StockValue, Loc.InventoryValuation, new { @class = "col-md-3 control-label", @title = Loc.InventoryValuation })
                            <div class="col-md-9">
                                @Html.DropDownListFor(model => model.SubjectEditData.StockValue, new List<SelectListItem>
                                 {
                                    new SelectListItem{ Text = StockType.NoManagement + " - " + Loc.NoManagement, Value = StockType.NoManagement },
                                    new SelectListItem{ Text = StockType.FIFO + " - " + Loc.StockManagementFIFO, Value = StockType.FIFO },
                                    new SelectListItem{ Text = StockType.LIFO + " - " + Loc.StockManagementLIFO, Value = StockType.LIFO },
                                    new SelectListItem{ Text = StockType.Average + " - " + Loc.StockManagementAverage, Value = StockType.Average },
                                    new SelectListItem{ Text = StockType.FixedPrice + " - " + Loc.PermanentPrice, Value = StockType.FixedPrice },
                                 }, HtmlAttributesHelper.CreateInputAttributes("form-control custom-select", "SubjectEditData_StockValue", false, Loc.InventoryValuation))
                                @Html.ValidationMessageFor(model => model.SubjectEditData.StockValue, "", new { @class = "text-danger", @id = "SubjectEditData_StockValue-validation" })
                            </div>
                        </div>
                        <div class="form-group">
                            @Html.LabelFor(model => model.SubjectEditData.DateInventory, Loc.LastInventoryDate, new { @class = "col-md-3 control-label", @title = Loc.LastInventoryDate })
                            <div class="col-md-9">
                                <div class="input-group">
                                    <span class="input-group-addon">
                                        <i class="far fa-calendar alt"></i>
                                    </span>
                                    @Html.TextBoxFor(model => model.SubjectEditData.DateInventory, Model.SubjectEditData.DateInventory.HasValue ?
                                    Model.SubjectEditData.DateInventory.Value.ToString(Loc.DateFormat) : null,
                                    HtmlAttributesHelper.CreateInputAttributes("form-control datepicker", "SubjectEditData_DateInventory", false, Loc.LastInventoryDate))
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
}

<div class="modal inmodal fade" id="vatValidationModal" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-body">
                <span id="vatValidationModalMessage"></span>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" data-dismiss="modal" onclick="">@Loc.OK</button>
            </div>
        </div>
    </div>
</div>

<input id="subjectTypeCreate" hidden />

<div class="modal inmodal fade" id="errorModal" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-body">
                <span id="errorModalMessage"></span>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" data-dismiss="modal" onclick="">@Loc.OK</button>
            </div>
        </div>
    </div>
</div>

<div class="modal inmodal top-25p fade" id="subjectTrrModal" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-xl" role="document">
        <div class="modal-content">
            <div class="modal-body p-sm">
                <div class="row">
                    <div class="col-xs-10">
                        <h3>@Loc.SubjectAccounts</h3>
                    </div>
                    <div class="col-xs-2 text-right">
                        <a class="btn-transparent m-r-sm" href="@Loc.HelpUrl@HelpIds.SubjectsTrrAccounts" target="_blank" title="@Loc.CheckInstructions"><i class="fas fa-question clickable-icon"></i></a>
                        <i class="fa fa-times clickable-icon" data-dismiss="modal" title="@Loc.Close"></i>
                    </div>
                </div>
                <div class="subject-contacts-table">
                    <table id="subject-trr-accounts" class="table table-bordered" role="grid">
                        <thead>
                            <tr role="row">
                                <th width="5%" class="text-center">@Loc.Default</th>
                                <th width="30%">@Loc.Invoice</th>
                                <th width="26%">@Loc.Bank</th>
                                <th width="26%">@Loc.Note</th>
                                <th width="10%" class="text-center">@Loc.Closed</th>
                                <th width="3%"></th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr role="row">
                                <td class="text-center no-padding">
                                    <input class="custom-checkbox" type="checkbox" id="subjectAccountDefaultValue" />
                                </td>
                                <td class="no-padding">
                                    <input class="form-control" id="subjectAccountNumberValue" maxlength="40" autocomplete="off" />
                                </td>
                                <td class="no-padding">
                                    <input class="form-control typeahead_3" id="subjectAccountBankValue" autocomplete="off" />
                                </td>
                                <td class="no-padding">
                                    <input class="form-control" id="subjectAccountNoteValue" autocomplete="off" />
                                </td>
                                <td class="text-center no-padding">
                                    <input class="custom-checkbox" type="checkbox" id="subjectAccountClosedValue" />
                                </td>
                                <td class="text-center no-padding">
                                    <button type="button" class="btn btn-primary btn-table-add" onclick="AddSubjectBankAccount()"><i class="fa fa-plus"></i></button>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" data-dismiss="modal" onclick="">@Loc.OK</button>
            </div>
        </div>
    </div>
</div>

<div class="modal inmodal top-25p fade" id="subjectLumpContractsModal" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-xl" role="document">
        <div class="modal-content">
            <div class="modal-body p-sm">
                <div class="row">
                    <div class="col-xs-10">
                        <h3>@Loc.LumpSumContracts</h3>
                    </div>
                    <div class="col-xs-2 text-right">
                        <a class="btn-transparent m-r-sm" href="@SiteHelpAttributeHelper.GetHelpUrl(HelpIds.SubjectsLumpContracts)" target="_blank" title="@Loc.CheckInstructions"><i class="fas fa-question clickable-icon"></i></a>
                        <i class="fa fa-times clickable-icon" data-dismiss="modal" title="@Loc.Close"></i>
                    </div>
                </div>
                <div class="subject-contacts-table">
                    <table id="subject-lump-contracts" class="table table-bordered" role="grid">
                        <thead>
                            <tr role="row">
                                <th width="10%" class="text-center">@Loc.SerialNumberShort</th>
                                <th width="35%">@Loc.ContractNumber</th>
                                <th width="26%">@Loc.ValidFrom</th>
                                <th width="26%">@Loc.ValidTo</th>
                                <th width="3%"></th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr role="row">
                                <td class="text-center no-padding">
                                    <input class="form-control" autocomplete="off" id="subjectLumpContractSerialNum" />
                                </td>
                                <td class="no-padding">
                                    <input class="form-control" id="subjectLumpContractNumber" autocomplete="off" />
                                </td>
                                <td class="no-padding">
                                    <input class="form-control datepicker" id="subjectLumpContractDateFrom" autocomplete="off" />
                                </td>
                                <td class="no-padding">
                                    <input class="form-control datepicker" id="subjectLumpContractDateTo" autocomplete="off" />
                                </td>
                                <td class="text-center no-padding">
                                    <button type="button" class="btn btn-primary btn-table-add" onclick="AddSubjectLumpContract()"><i class="fa fa-plus"></i></button>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" data-dismiss="modal" onclick="">@Loc.OK</button>
            </div>
        </div>
    </div>
</div>

@{Html.RenderPartial("~/Views/Shared/Components/_SubjectWayOfSaleChangedModal.cshtml");}

@Html.Partial("~/Views/TravelOrderAllData/_GoogleAPIKeyExpiredIRIS.cshtml", Model)

<input type="hidden" id="LocNoResults" value="@Loc.NoResults" />
<input type="hidden" id="subjectContactEmail" value="@SubjectContact.Email" />
<input type="hidden" id="subjectContactPhone" value="@SubjectContact.Phone" />
<input type="hidden" id="subjectContactUrl" value="@SubjectContact.Url" />
<input type="hidden" id="subjectContactFax" value="@SubjectContact.Fax" />
<input type="hidden" id="subjectContactEmailLoc" value="@Loc.Email" />
<input type="hidden" id="subjectContactPhoneLoc" value="@Loc.Telefon" />
<input type="hidden" id="subjectContactUrlLoc" value="@Loc.Link" />
<input type="hidden" id="subjectContactFaxLoc" value="@Loc.Fax" />
<input type="hidden" id="LocAjpesNoResults" value="@Loc.AjpesSearchNoResults" />
<input type="hidden" id="TabsReturnMethod" value="@(!string.IsNullOrEmpty(ViewBag.ReturnUrl) ? "initializeCashRegisterCashRegister" : "")" />
<input type="hidden" id="VatValidationWarning" value="@Loc.SubjectWithThisVatAlreadyExists" />
<input type="hidden" id="InvalidVATWarning" value="@Loc.InvalidVAT" />
<input type="hidden" id="EnteredSubjectDoesNotExistCreateNewLoc" value="@Loc.EnteredSubjectDoesNotExistCreateNew" />
<input type="hidden" id="YesLoc" value="@Loc.Yes" />
<input type="hidden" id="NoLoc" value="@Loc.No" />
<input type="hidden" id="GetSubjectBankAccountsUrl" value="@Url.Action("GetSubjectBankAccounts", "Subjects")" />
<input type="hidden" id="GetSubjectLumpContractsUrl" value="@Url.Action("GetSubjectLumpContracts", "Subjects")" />
<input type="hidden" id="IsEUISOCodeUrl" value="@Url.Action("IsEUISOCode", "Country")" />
<input type="hidden" id="SearchBanksUrl" value="@Url.Action("SearchBanks", "Subjects")" />
<input type="hidden" id="GetBankByCodeUrl" value="@Url.Action("GetBankNameByCode", "Subjects")" />
<input type="hidden" id="GetVATValidationUrl" value="@Url.Action("GetVATValidation", "Subjects")" />
<input type="hidden" id="FieldRequiredForCreatingKeyLoc" value="@Loc.FieldRequiredForCreatingKey" />
<input type="hidden" id="FieldDoesNotExistLoc" value="@Loc.FieldDoesNotExist" />
<input type="hidden" id="WayOfSaleFlatrate" value="@WayOfSale.Flatrate" />
<input type="hidden" id="ContractAlreadyExistsForSelectedPeriodLoc" value="@Loc.ContractAlreadyExistsForSelectedPeriod" />

@helper GDPRInput(bool canViewData, string inputName, string text, string placeholder, string inputClass = null, object url = null, string maxlength = null, bool isReadonly = false)
{
    if (canViewData)
    {
        if (isReadonly)
        {
@Html.TextBox(inputName.Replace('_', '.'), text, new
{
    @class = string.IsNullOrEmpty(inputClass) ? "form-control" : inputClass,
    @placeholder = placeholder,
    autocomplete = "chrome-off",
    @id = inputName,
    dataUrl = url,
    @maxlength = (!string.IsNullOrEmpty(maxlength) ? maxlength : string.Empty),
    @readonly = "true"
})
        }
        else
        {
@Html.TextBox(inputName.Replace('_', '.'), text, new
{
    @class = string.IsNullOrEmpty(inputClass) ? "form-control" : inputClass,
    @placeholder = placeholder,
    @autocomplete = "chrome-off",
    @id = inputName,
    dataUrl = url,
    @maxlength = (!string.IsNullOrEmpty(maxlength) ? maxlength : string.Empty),
})
        }
    }
    else
    {
@Html.Password(inputName, text, new { @class = string.IsNullOrEmpty(inputClass) ? "form-control" : inputClass, @placeholder = placeholder, @readonly = "", @id = inputName + "-validation" })
    }
@Html.ValidationMessage(inputName, new { @class = "text-danger", @id = inputName + "-validation" })
}
<script src="~/Scripts/custom/travelorders/google-map.js"></script>

<script>
    $.ajax({
        url: $("#GetGoogleApiKeyUrl").val(),
        type: "GET",
        success: function (apiKey) {
            if (apiKey) {
                if (@isTravelOrder != true) generateScript(apiKey);
                ensureApiIsLoaded();
            }
        }
    });

    function initGoogleMapsSearch() {
        var postalCode;
        var postalCodePrefix;
        var country;
        var input = document.getElementById('SubjectEditData_Address');
        var options = {
            types: ['address']
        };
        var autocomplete = new google.maps.places.Autocomplete(input, options);

        selectFirstOnEnter(input);

        google.maps.event.addListener(autocomplete, 'place_changed', function () {
            var place = autocomplete.getPlace();
            var address = place.name;
            $("#SubjectEditData_Address").val(address);

            for (var i = 0; i < place.address_components.length; i++) {
                for (var j = 0; j < place.address_components[i].types.length; j++) {
                    if (place.address_components[i].types[j] == "country") postalCodePrefix = place.address_components[i].short_name;
                    if (place.address_components[i].types[j] == "postal_code") postalCode = place.address_components[i].long_name;
                    if (place.address_components[i].types[j] == "country") country = place.address_components[i].long_name;
                }
            }

            if (postalCode) {
                $("#SubjectEditData_ZipCode").val(postalCodePrefix + "-" + postalCode);
            } else {
                $("#SubjectEditData_ZipCode").val("");
            }
            setDropdownSelectedValue("SubjectEditData_SelectedCountryId", country);
        });

        $("#SubjectEditData_Address").blur(function () {
            setTimeout(() => {
                if ($("#SubjectEditData_Address").hasClass("gm-err-autocomplete")) {
                    $("#IRISContinueClickable").attr("onclick", "switchToPlainSearch()");
                    $("#IRISContinueText").text("@Loc.ContinueUsingExpiredGoogleMapKeySubject");
                    $('#google-api-key-expired-iris').modal('show');
                }
            }, "100")
        });
    }

     function generateScript(apiKey) {
         var script = document.createElement("script");
         script.type = "text/javascript";
         script.src = "https://maps.googleapis.com/maps/api/js?language=" + "@languageCode" + "&libraries=places&key=" + apiKey + "";
         $("body").append(script);
    }

    function ensureApiIsLoaded() {
        if (typeof google == 'undefined') {
            setTimeout(ensureApiIsLoaded, 125);
            return;
        } else {
            initGoogleMapsSearch();
        }
    };
</script>