@model PantheonRA.BackOffice.Models.DocTypeCreateViewModel
@using PantheonRA.BackOffice.Models
@using PantheonRA.WebApi.Contracts.Enums
@using PAW.Contracts.Enums;
@using PAW.Contracts.Helpers;
@{
    ViewBag.Title = Model.IsEdit ? Loc.CreateNewDocumentType : Loc.EditDocumentType;
    var isInFiscalPrinterLocalization = Localization.IsInFiscalPrinterLocalization(PantheonRA.BackOffice.CurrentUser.DatabaseLocalization, PantheonRA.BackOffice.CurrentUser.IsInServerFiscalization);
    bool isTravelOrder = Model.IsTravelOrder;
    bool showArchive = Model.ShowArchive;
    var showOnTO = isTravelOrder ? string.Empty : "hidden";
    var hideOnTO = !isTravelOrder ? string.Empty : "hidden";
    var newExpenseRowNum = -1;
}

@Html.Hidden("PreSelectedSerialNumbers", Model.SelectedSerialNumbers != null ? string.Join(",", Model.SelectedSerialNumbers) : null)

<div class="tabs-container">
    @Html.Partial("~/Views/Company/_CompanySettingsTabNavigation.cshtml")
    <div class="tab-content">
        <form id="mainForm" method="post">
            @Html.HiddenFor(model => model.MachineName)
            @Html.HiddenFor(model => model.SetOf)
            @Html.HiddenFor(model => model.TypeOfDoc)
            @Html.HiddenFor(model => model.ShowFiscalizeOptions)
            @Html.HiddenFor(model => model.IsTravelOrder, isTravelOrder)
            <div class="row buttons-tabbed">
                @Html.Partial("_FormButtons", new FormButtonsViewModel
                {
                    BackUrl = Url.Action("Index", "DocumentType"),
                    SaveButtonGroup = new FormButtonGroup
                    {
                        Buttons = new List<FormButton>
                        {
                            new FormButton { Text = Loc.Save, Icon = "fa fa-save fa-lg", IsSubmit = false }
                        }
                    }
                })
            </div>
            <div class="divided-content clearfix">
                <div class="divided-content-main divided-content-full">
                    <div class="form-horizontal form-md row">
                        <div class="col-sm-6 col-lg-5 column-full-height-border-right">
                            <h3 class="m-b-md m-t-md">@Loc.BasicData</h3>
                            @Html.HiddenFor(model => model.IsEdit)
                            @Html.HiddenFor(model => model.AnQid)
                            <div class="form-group">
                                @Html.LabelFor(model => model.Id, Loc.Code, new { @class = "col-md-3 control-label" })
                                <div class="col-md-9">
                                    @if (!Model.IsEdit)
                                    {
                                        @*TODO: implement according to settings when edit implemented*@
                                    }
                                    else
                                    {
                                        @Html.HiddenFor(model => model.Id)
                                        @Html.TextBoxFor(model => model.IdView, new { @id = "Id", @class = "form-control", @readonly = "readonly" })
                                        @Html.ValidationMessageFor(model => model.Id, "", new { @class = "text-danger", @id = "Id-validation" })
                                    }
                                </div>
                            </div>

                            <div class="form-group">
                                @Html.LabelFor(model => model.Evidence, Loc.Evidence, new { @class = "col-md-3" })
                                <div class="col-md-9">
                                    @Html.CheckBoxFor(model => model.Evidence, new { @class = "form-control js-switch js-switch-small", autocomplete = "off" })
                                    @Html.ValidationMessageFor(model => model.Evidence, "", new { @class = "text-danger block", @id = "Evidence-validation" })
                                </div>
                            </div>

                            @if (Model.SetOf == "N")
                            {
                                <div class="form-group">
                                    @Html.LabelFor(model => model.Receiver, (Model.Type == "P" ? Loc.Buyer : Loc.Recipient), new { @class = "col-md-3 control-label" })
                                    <div class="col-md-8">
                                        <select id="Receiver"
                                                name="Receiver"
                                                class="form-control select2withAPI"
                                                data-placeholder="@(Model.Type == "P" ? Loc.Buyer : Loc.Recipient)"
                                                data-column-names="@Loc.Company,@Loc.Name,@Loc.Address,@Loc.Post"
                                                data-bootstrap-columns="col-md-4,col-md-3,col-md-3,col-md-2"
                                                data-search-width="450"
                                                data-allow-clear="true"
                                                data-url=@Url.Action("SubjectDropdownValues", "Subjects")>
                                            <option selected value="@Model.Receiver">@Model.Receiver</option>
                                        </select>
                                    </div>
                                    <div class="col-md-1 m-t-sm">
                                        @Html.CheckBoxFor(model => model.IsObligReceiver, new { @class = "form-control js-switch js-switch-small", autocomplete = "off" })
                                    </div>
                                </div>
                                <div class="form-group">
                                    @Html.LabelFor(model => model.Issuer, Loc.Warehouse, new { @class = "col-md-3 control-label" })
                                    <div class="col-md-9">
                                        @Html.DropDownListFor(model => model.Issuer, new SelectList(ViewBag.Warehouses, "Id", "Name"), "", new { @class = "form-control custom-select" })
                                    </div>
                                </div>
                            }
                            else if (Model.SetOf == "F" && Model.Type == "P")
                            {
                                <div class="form-group">
                                    @Html.LabelFor(model => model.Receiver, Loc.Recipient, new { @class = "col-md-3 control-label" })
                                    <div class="col-md-9">
                                        @Html.DropDownListFor(model => model.Receiver, new SelectList(ViewBag.Warehouses, "Id", "Name"), "", new { @class = "form-control custom-select" })
                                    </div>
                                </div>
                                <div class="form-group">
                                    @Html.LabelFor(model => model.Issuer, Loc.Issuer, new { @class = "col-md-3 control-label" })
                                    <div class="col-md-8">
                                        <select id="Issuer"
                                                name="Issuer"
                                                class="form-control select2withAPI"
                                                data-placeholder="@Loc.Issuer"
                                                data-column-names="@Loc.Company,@Loc.Name,@Loc.Address,@Loc.Post"
                                                data-bootstrap-columns="col-md-4,col-md-3,col-md-3,col-md-2"
                                                data-search-width="450"
                                                data-allow-clear="true"
                                                data-url=@Url.Action("SubjectDropdownValues", "Subjects")>
                                            <option selected value="@Model.Issuer">@Model.Issuer</option>
                                        </select>
                                    </div>
                                    <div class="col-md-1 m-t-sm">
                                        @Html.CheckBoxFor(model => model.IsObligIssuer, new { @class = "form-control js-switch js-switch-small", autocomplete = "off" })
                                    </div>
                                </div>
                            }
                            else if (Model.SetOf == "F" && (Model.Type == "I" || Model.Type == "M"))
                            {
                                <div class="form-group">
                                    @Html.LabelFor(model => model.Issuer, Loc.Issuer, new { @class = "col-md-3 control-label" })
                                    <div class="col-md-9">
                                        @Html.DropDownListFor(model => model.Issuer, new SelectList(ViewBag.Warehouses, "Id", "Name"), "", new { @class = "form-control custom-select" })
                                    </div>
                                </div>
                                <div class="form-group">
                                    @Html.LabelFor(model => model.Receiver, Loc.Recipient, new { @class = "col-md-3 control-label" })
                                    <div class="col-md-8">
                                        <select id="Receiver"
                                                name="Receiver"
                                                class="form-control select2withAPI"
                                                data-placeholder="@Loc.Buyer"
                                                data-column-names="@Loc.Company,@Loc.Name,@Loc.Address,@Loc.Post"
                                                data-bootstrap-columns="col-md-4,col-md-3,col-md-3,col-md-2"
                                                data-search-width="450"
                                                data-allow-clear="true"
                                                data-url=@Url.Action("SubjectDropdownValues", "Subjects")>
                                            <option selected value="@Model.Receiver">@Model.Receiver</option>
                                        </select>
                                    </div>
                                    <div class="col-md-1 m-t-sm">
                                        @Html.CheckBoxFor(model => model.IsObligReceiver, new { @class = "form-control js-switch js-switch-small", autocomplete = "off" })
                                    </div>
                                </div>
                            }
                            else if (Model.SetOf == "F" && Model.Type == "E")
                            {
                                <div class="form-group">
                                    @Html.LabelFor(model => model.Issuer, Loc.Issuer, new { @class = "col-md-3 control-label" })
                                    <div class="col-md-9">
                                        @Html.DropDownListFor(model => model.Issuer, new SelectList(ViewBag.Warehouses, "Id", "Name"), "", new { @class = "form-control custom-select" })
                                    </div>
                                </div>
                                <div class="form-group">
                                    @Html.LabelFor(model => model.Receiver, Loc.Recipient, new { @class = "col-md-3 control-label" })
                                    <div class="col-md-9">
                                        @Html.DropDownListFor(model => model.Receiver, new SelectList(ViewBag.Warehouses, "Id", "Name"), "", new { @class = "form-control custom-select" })
                                    </div>
                                </div>
                            }

                            <div class="form-group">
                                @Html.LabelFor(model => model.ShortName, Loc.ShortName, new { @class = "col-md-3 control-label" })
                                <div class="col-md-9">
                                    @Html.TextBoxFor(model => model.ShortName, new { @class = "form-control", autocomplete = "off" })
                                    @Html.ValidationMessageFor(model => model.ShortName, "", new { @class = "text-danger", @id = "ShortName-validation" })
                                </div>
                            </div>

                            <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, new { @class = "form-control", autocomplete = "off" })
                                    @Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger", @id = "Name-validation" })
                                </div>
                            </div>

                            @if (showArchive)
                            {
                                <div class="form-group">
                                    @Html.LabelFor(model => model.Archive, Loc.Archive, new { @class = "col-md-3 control-label" })
                                    <div class="col-md-9">
                                        <select id="Archive"
                                                name="Archive"
                                                class="form-control select2withAPI"
                                                data-placeholder="@Loc.Archive"
                                                data-column-names="@Loc.DocType, @Loc.Name"
                                                data-bootstrap-columns="col-md-6, col-md-6"
                                                data-search-width="450"
                                                data-allow-clear="true"
                                                data-url=@Url.Action("DocumentTypeDropDownValues", "DocumentType", new { setOf = "Y", type = "M" })>
                                            <option selected value="@Model.Archive">@Model.ArchiveFullName</option>
                                        </select>
                                    </div>
                                </div>
                            }

                            <div class="form-group">
                                @Html.LabelFor(model => model.Classification, Loc.Classification, new { @class = "col-md-3 control-label" })
                                <div class="col-md-9">
                                    <select id="Classification"
                                            name="Classification"
                                            class="form-control select2withAPI"
                                            data-placeholder="@Loc.Classification"
                                            data-column-names="@Loc.Description,@Loc.Code"
                                            data-bootstrap-columns="col-md-10, col-md-2"
                                            data-search-width="450"
                                            data-allow-clear="true"
                                            data-url=@Url.Action("ClassificationDropdownValues", "Classification")>
                                        <option selected value="@Model.Classification">@Model.ClassificationFullName</option>
                                    </select>
                                </div>
                            </div>

                            @if (!(Model.SetOf == "Y" && Model.Type == "M"))
                            {
                                if (Model.ShowEInvoiceExportType == true)
                                {
                                    if (PantheonRA.BackOffice.CurrentUser.DatabaseLocalization == Localization.Code.RS)
                                    {
                                        <div class="form-group" id="acEInvoiceExportTypeContainer">
                                            @Html.LabelFor(model => model.EInvoiceExportType2, Loc.ExportTypeEDocument, new { @class = "col-md-3 control-label" })
                                            <div class="col-md-9">
                                                @Html.DropDownListFor(model => model.EInvoiceExportType2, new List<SelectListItem> {
                                                    new SelectListItem{ Text = "0 - " + Loc.GeneralDocument, Value = "0"},
                                                    new SelectListItem{ Text = "4 - " + Loc.WarningType, Value = "4"},
                                                    new SelectListItem{ Text = "7 - " + Loc.AnswerConsentOrRefusal, Value = "7"},
                                                    new SelectListItem{ Text = "105 - " + Loc.OrderFormExportType, Value = "105"},
                                                    new SelectListItem{ Text = "226 - " + Loc.OrderRevocation, Value = "226"},
                                                    new SelectListItem{ Text = "230 - " + Loc.OrderChange, Value = "230"},
                                                    new SelectListItem{ Text = "231 - " + Loc.OrderResponse, Value = "231"},
                                                    new SelectListItem{ Text = "325 - " + Loc.OrderBuyer, Value = "325"},
                                                    new SelectListItem{ Text = "326 - " + Loc.PartialAccount, Value = "326"},
                                                    new SelectListItem{ Text = "351 - " + Loc.OrderForm, Value = "351"},
                                                    new SelectListItem{ Text = "380 - " + Loc.CommercialFinalAccount, Value = "380"},
                                                    new SelectListItem{ Text = "381 - " + Loc.Approval, Value = "381"},
                                                    new SelectListItem{ Text = "383 - " + Loc.Indebtedness, Value = "383"},
                                                    new SelectListItem{ Text = "384 - " + Loc.CorrectiveAccount, Value = "384"},
                                                    new SelectListItem{ Text = "386 - " + Loc.AdvancePaymentInvoice, Value = "386"},
                                                    new SelectListItem{ Text = "394 - " + Loc.LeasingAccount, Value = "394"},
                                                    new SelectListItem{ Text = "632 - " + Loc.ReceiptType, Value = "632"},
                                                }, "", new { @class = "form-control custom-select" })
                                            </div>
                                        </div>
                                    }
                                    else if (PantheonRA.BackOffice.CurrentUser.DatabaseLocalization == Localization.Code.SI)
                                    {
                                        <div class="form-group" id="acEInvoiceExportTypeContainer">
                                            @Html.LabelFor(model => model.DocTypeESLOG, Loc.ESlogAccountType, new { @class = "col-md-3 control-label" })
                                            <div class="col-md-9">
                                                @Html.DropDownListFor(model => model.DocTypeESLOG, new List<SelectListItem> {
                                                    new SelectListItem{ Text = "82 - " + Loc.EInvoiceType82, Value = "82" },
                                                    new SelectListItem{ Text = "83 - " + Loc.EInvoiceType83, Value = "83"},
                                                    new SelectListItem{ Text = "84 - " + Loc.EInvoiceType84, Value = "84"},
                                                    new SelectListItem{ Text = "130 - " + Loc.EInvoiceType130, Value = "130"},
                                                    new SelectListItem{ Text = "325 - " + Loc.EInvoiceType325, Value = "325"},
                                                    new SelectListItem{ Text = "380 - " + Loc.EInvoiceType380, Value = "380"},
                                                    new SelectListItem{ Text = "381 - " + Loc.EInvoiceType381, Value = "381"},
                                                    new SelectListItem{ Text = "382 - " + Loc.EInvoiceType382, Value = "382"},
                                                    new SelectListItem{ Text = "383 - " + Loc.EInvoiceType383, Value = "383"},
                                                    new SelectListItem{ Text = "384 - " + Loc.EInvoiceType384, Value = "384"},
                                                    new SelectListItem{ Text = "385 - " + Loc.EInvoiceType385, Value = "385"},
                                                    new SelectListItem{ Text = "386 - " + Loc.EInvoiceType386, Value = "386"},
                                                    new SelectListItem{ Text = "387 - " + Loc.EInvoiceType387, Value = "387"},
                                                    new SelectListItem{ Text = "389 - " + Loc.EInvoiceType389, Value = "389"},
                                                    new SelectListItem{ Text = "38P - " + Loc.EInvoiceType38P, Value = "38P"},
                                                    new SelectListItem{ Text = "390 - " + Loc.EInvoiceType390, Value = "390"},
                                                    new SelectListItem{ Text = "393 - " + Loc.EInvoiceType393, Value = "393"},
                                                }, "", new { @class = "form-control custom-select" })
                                            </div>
                                        </div>
                                    }
                                    else if (PantheonRA.BackOffice.CurrentUser.DatabaseLocalization == Localization.Code.HR)
                                    {
                                        <div class="form-group" id="acEInvoiceExportTypeContainer">
                                            @Html.LabelFor(model => model.EInvoiceExportType, Loc.EInvoiceExportType, new { @class = "col-md-3 control-label" })
                                            <div class="col-md-9">
                                                @Html.DropDownListFor(model => model.EInvoiceExportType, new List<SelectListItem> {
                                                    new SelectListItem{ Text = Loc.Invoice, Value = "" },
                                                    new SelectListItem{ Text = Loc.CreditNotification, Value = "C"},
                                                    new SelectListItem{ Text = Loc.Charge, Value = "D"},
                                                    new SelectListItem{ Text = Loc.AdvancePaymentInvoice, Value = "B"},
                                                }, null, new { @class = "form-control custom-select" })
                                            </div>
                                        </div>
                                    }
                                }

                                if (isTravelOrder)
                                {
                                    <div class="form-group">
                                        @Html.LabelFor(model => model.Worker, Loc.EmployeeTR, new { @class = "col-md-3 control-label" })
                                        <div class="col-md-9">
                                            <select id="Worker"
                                                    name="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="700"
                                                    data-allow-clear="true"
                                                    data-url=@Url.Action("EmployeeDropDownValues", "Employees")>
                                                <option selected value="@Model.Worker">@Model.Worker</option>
                                            </select>
                                        </div>
                                    </div>
                                }

                                if (Model.IsEdit && !isTravelOrder)
                                {
                                    <div class="form-group" id="printSettings">
                                        <label class="col-md-3">@Loc.PrintSettings</label>
                                        <div class="col-md-9">
                                            @if (isInFiscalPrinterLocalization)
                                            {
                                                <div>
                                                    <span>@Loc.InvoicePrint</span>
                                                    @Html.DropDownListFor(model => model.DefaultFiscalDevice,
                                                     new SelectList(ViewBag.FiscalDevices, "AnQid", "AcDeviceName"), "- " + Loc.Select + " -",
                                                     new { @class = "form-control custom-select auto-width m-l-sm", disabled = "disabled" })
                                                </div>
                                            }
                                            else
                                            {
                                                <select id="DefaultReport" name="DefaultReport" class="form-control custom-select">
                                                    @foreach (var item in ViewBag.ReportPrintOptions)
                                                    {
                                                        <option value="@item.Report" @(Model.DefaultReport == item.Report ? "selected" : string.Empty)>
                                                            @(item.Report) - @(item.Name)
                                                        </option>
                                                    }
                                                </select>
                                            }
                                        </div>
                                    </div>
                                }

                                if (!isTravelOrder)
                                {
                                    if (PantheonRA.BackOffice.CurrentUser.DatabaseLocalization == Localization.Code.RS)
                                    {
                                        <div class="form-group fiscalData @(Model.CanFiscalize == false ? "hidden" : "")">
                                            @Html.LabelFor(model => model.Note, Loc.Note, new { @class = "col-md-3" })
                                            <div class="col-md-9">
                                                @Html.TextAreaFor(model => model.Note, new { @class = "form-control", rows = 3, autocomplete = "off" })
                                            </div>
                                        </div>
                                    }

                                    <div class="form-group">
                                        <label class="col-md-3 control-label">@Loc.DefaultNote</label>
                                        <div class="col-md-9">
                                            @Html.TextAreaFor(model => model.DefaultNote, new { @class = "form-control", rows = 3 })
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        @Html.LabelFor(model => model.PayMethod, Loc.DefaultPaymentMethod, new { @class = "col-md-3 control-label" })
                                        <div class="col-md-9">
                                            <select id="PayMethod" name="PayMethod" class="form-control custom-select">
                                                <option></option>
                                                @foreach (var item in ViewBag.PaymentMethods)
                                                {
                                                    <option value="@item.PaymentMethod" @(Model.PayMethod == item.PaymentMethod ? "selected" : string.Empty)>
                                                        @(item.PaymentMethod) - @(string.IsNullOrEmpty(item.FiscalGroup) ? item.Name : item.FiscalGroup + " - " + item.Name)
                                                    </option>
                                                }
                                            </select>
                                            @Html.ValidationMessageFor(model => model.PayMethod, "", new { @class = "text-danger", @id = "PayMethod-validation" })
                                        </div>
                                    </div>

                                    <div class="form-group pos-settings">
                                        @Html.LabelFor(model => model.PayMethodRefund, Loc.DefaultPaymentMethodRefund, new { @class = "col-md-3 control-label" })
                                        <div class="col-md-9">
                                            <select id="PayMethodRefund" name="PayMethodRefund" class="form-control custom-select">
                                                <option value=" "></option>
                                                @foreach (var item in ViewBag.PaymentMethods)
                                                {
                                                    <option value="@item.PaymentMethod" @(Model.PayMethodRefund == item.PaymentMethod ? "selected" : string.Empty)>
                                                        @(item.PaymentMethod) - @(string.IsNullOrEmpty(item.FiscalGroup) ? item.Name : item.FiscalGroup + " - " + item.Name)
                                                    </option>
                                                }
                                            </select>
                                            @Html.ValidationMessageFor(model => model.PayMethodRefund, "", new { @class = "text-danger", @id = "PayMethodRefund-validation" })
                                        </div>
                                    </div>

                                    if (Model.SetOf != "N")
                                    {
                                        <div class="form-group">
                                            <label class="col-md-3 control-label">@Loc.Type</label>
                                            <div class="col-md-9">
                                                @Html.DropDownListFor(model => model.Type, new List<SelectListItem> {
                                                    new SelectListItem{ Text = Loc.Retail, Value = DocumentTypeAcType.Retail},
                                                    new SelectListItem{ Text = Loc.Wholesale, Value = DocumentTypeAcType.Wholesale},
                                                    new SelectListItem{ Text = Loc.Receive, Value = DocumentTypeAcType.Supply},
                                                }, "", new { @class = "form-control custom-select" })
                                                @Html.ValidationMessageFor(model => model.Type, "", new { @class = "text-danger", @id = "Type-validation" })
                                            </div>
                                        </div>
                                    }
                                    else
                                    {
                                        @Html.HiddenFor(model => model.Type);
                                    }

                                    <div class="form-group" id="allowZeroTotalContainer">
                                        @Html.LabelFor(model => model.Evidence, Loc.AllowZeroSumDocument, new { @class = "col-md-3" })
                                        <div class="col-md-9">
                                            @Html.CheckBoxFor(model => model.AllowZeroTotal, new { @class = "form-control js-switch js-switch-small", autocomplete = "off" })
                                            @Html.ValidationMessageFor(model => model.AllowZeroTotal, "", new { @class = "text-danger block", @id = "AllowZeroTotal-validation" })
                                        </div>
                                    </div>

                                    if (Model.SetOf == "N")
                                    {
                                        <div class="form-group" style="margin-bottom: 30px">
                                            <label class="col-md-3 control-label">@Loc.EnterSerialNumber</label>
                                            <div class="col-md-9">
                                                @Html.DropDownListFor(model => model.SelectedSerialNumbers,
                                                     new SelectList(Model.SerialNumbers, "Id", "Name", Model.SelectedSerialNumbers),
                                                     HtmlAttributesHelper.CreateInputAttributes("form-control selectpicker",
                                                         "SelectedSerialNumbers", false, Loc.ProductMenuSerialNoTitle, true, new { @multiple = "multiple", data_live_search = "true", @title = Loc.ProductMenuSerialNoTitle }))
                                                @Html.ValidationMessageFor(model => model.SelectedSerialNumbers, "", new { @class = "text-danger", @id = "SelectedSerialNumbers-validation" })
                                            </div>
                                        </div>
                                    }

                                    <div class="form-group" id="checkPositionPriceQtyContainer">
                                        @Html.LabelFor(model => model.CheckPositionPriceQty, Loc.CheckPositionPriceAndQuantity, new { @class = "col-md-3" })
                                        <div class="col-md-9">
                                            @Html.CheckBoxFor(model => model.CheckPositionPriceQty, new { @class = "form-control js-switch js-switch-small", autocomplete = "off" })
                                            @Html.ValidationMessageFor(model => model.CheckPositionPriceQty, "", new { @class = "text-danger block", @id = "CheckPositionPriceQty-validation" })
                                        </div>
                                    </div>

                                    if (PantheonRA.BackOffice.CurrentUser.Localization == Localization.Code.HR && (Model.Id == "8100" || Model.Id == "8010"))
                                    {
                                        <div class="form-group" id="checkCashRegIsTip">
                                            @Html.LabelFor(model => model.IsCashRegisTip, Loc.CashRegIsTip, new { @class = "col-md-3" })
                                            <div class="col-md-9">
                                                @Html.CheckBoxFor(model => model.IsCashRegisTip, new { @class = "form-control js-switch js-switch-small", autocomplete = "off" })
                                                @Html.ValidationMessageFor(model => model.IsCashRegisTip, "", new { @class = "text-danger block", @id = "IsCashRegisTip-validation" })
                                            </div>
                                        </div>
                                    }

                                    if (Model.SetOf == "N" && Model.Type == "P")
                                    {
                                        <div class="form-group" id="orderCalendarContainer">
                                            @Html.LabelFor(model => model.IsOrderCalendar, Loc.OrderCalendarLabel, new { @class = "col-md-3" })
                                            <div class="col-md-9">
                                                @Html.CheckBoxFor(model => model.IsOrderCalendar, new { @class = "form-control js-switch js-switch-small", autocomplete = "off" })
                                                @Html.ValidationMessageFor(model => model.IsOrderCalendar, "", new { @class = "text-danger block", @id = "IsOrderCalendar-validation" })
                                            </div>
                                        </div>

                                        <div class="form-group @(!Model.IsOrderCalendar ? "hidden" : "")" id="DocTypeForPOS-container">
                                            @Html.LabelFor(model => model.DocTypeForPOS, Loc.DocTypeForPOS, new { @class = "col-md-3 control-label" })
                                            <div class="col-md-9">
                                                <select id="DocTypeForPOS"
                                                        name="DocTypeForPOS"
                                                        class="form-control select2withAPI"
                                                        data-placeholder="@Loc.DocTypeForPOS"
                                                        data-column-names="@Loc.DocType, @Loc.Name"
                                                        data-bootstrap-columns="col-md-4, col-md-8"
                                                        data-search-width="450"
                                                        data-allow-clear="true"
                                                        data-url=@Url.Action("POSDocumentTypeDropdownValues", "DocumentType")>
                                                    <option selected value="@Model.DocTypeForPOS">@Model.DocTypeNameForPOS</option>
                                                </select>
                                            </div>
                                        </div>
                                    }

                                    if (Model.TypeOfDocument == TypeOfDocument.Wholesale || Model.TypeOfDocument == TypeOfDocument.ReceivedBills ||
                                        Model.TypeOfDocument == TypeOfDocument.SupplierOrder || Model.TypeOfDocument == TypeOfDocument.BuyerOrder)
                                    {
                                        <div class="form-group" id="orderCalendarContainer">
                                            @Html.LabelFor(model => model.CheckIdentDpl, Loc.EnterDuplicateIdentWarning, new { @class = "col-md-3" })
                                            <div class="col-md-9">
                                                @Html.CheckBoxFor(model => model.CheckIdentDpl, new { @class = "form-control js-switch js-switch-small", autocomplete = "off" })
                                                @Html.ValidationMessageFor(model => model.CheckIdentDpl, "", new { @class = "text-danger block", @id = "CheckIdentDpl-validation" })
                                            </div>
                                        </div>
                                    }

                                    if (Model.TypeOfDocument == TypeOfDocument.POS)
                                    {
                                        <div class="form-group">
                                            @Html.LabelFor(model => model.MaximumCashAmount, Loc.MaximumCashAmount, new { @class = "col-md-3" })
                                            <div class="col-md-9">
                                                @Html.TextBoxFor(model => model.MaximumCashAmount, new { @class = "form-control numberInput", autocomplete = "off" })
                                                @Html.ValidationMessageFor(model => model.MaximumCashAmount, "", new { @class = "text-danger block", @id = "MaximumCashAmount-validation" })
                                            </div>
                                        </div>
                                    }
                                }

                                if (isTravelOrder)
                                {
                                    <div class="form-group">
                                        <label class="col-md-3 control-label">@Loc.TravelPurpose</label>
                                        <div class="col-md-9">
                                            @Html.TextAreaFor(model => model.Name2, new { @class = "form-control", rows = 3, maxlength = 40 })
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        @Html.LabelFor(model => model.Receiver, Loc.Payer, new { @class = "col-md-3 control-label" })
                                        <div class="col-md-9">
                                            <select id="Receiver"
                                                    name="Receiver"
                                                    class="form-control select2withAPI"
                                                    data-placeholder="@Loc.Payer"
                                                    data-column-names="@Loc.Company,@Loc.Name,@Loc.Address,@Loc.Post"
                                                    data-bootstrap-columns="col-md-4,col-md-3,col-md-3,col-md-2"
                                                    data-search-width="450"
                                                    data-allow-clear="true"
                                                    data-url=@Url.Action("SubjectDropdownValues", "Subjects")>
                                                <option selected value="@Model.Receiver">@Model.Receiver</option>
                                            </select>
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        @Html.LabelFor(model => model.Department, Loc.Department, new { @class = "col-md-3 control-label" })
                                        <div class="col-md-8">
                                            <select id="Department"
                                                    name="Department"
                                                    class="form-control select2withAPI"
                                                    data-placeholder="@Loc.Department"
                                                    data-search-width="350"
                                                    data-allow-clear="true"
                                                    data-url=@Url.Action("GetDepartments", "Employees")>
                                                <option selected value="@Model.Department">@Model.Department</option>
                                            </select>
                                        </div>
                                        <div class="col-md-1">
                                            @Html.CheckBoxFor(model => model.ISObligDept, new { @class = "form-control js-switch js-switch-small", autocomplete = "off" })
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        @Html.LabelFor(model => model.IsObligCostDrv, Loc.CostCarrierFull, new { @class = "col-md-3" })
                                        <div class="col-md-9">
                                            @Html.CheckBoxFor(model => model.IsObligCostDrv, new { @class = "form-control js-switch js-switch-small", autocomplete = "off" })
                                        </div>
                                    </div>
                                }
                            }

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

                        @if (Model.ShowFiscalizeOptions == true && !PantheonRA.BackOffice.CurrentUser.IsDemo && !isTravelOrder && PantheonRA.BackOffice.CurrentUser.Localization != Localization.Code.EU)
                        {
                            <div class="col-sm-6 col-lg-4">
                                <h3 class="m-b-md m-t-md">@Loc.Fiscalization</h3>

                                @if (PantheonRA.BackOffice.CurrentUser.DatabaseLocalization != Localization.Code.RS || !PantheonRA.BackOffice.CurrentUser.IsInServerFiscalization)
                                {
                                    <div class="form-group">
                                        @Html.LabelFor(model => model.CanFiscalize, Loc.FiscalizeInvoices, new { @class = "col-md-3" })
                                        <div class="col-md-9">
                                            @Html.CheckBoxFor(model => model.CanFiscalize, new { @class = "form-control js-switch js-switch-small", autocomplete = "off" })
                                            @Html.ValidationMessageFor(model => model.CanFiscalize, "", new { @class = "text-danger block", @id = "CanFiscalize-validation" })
                                        </div>
                                    </div>
                                }
                                else
                                {
                                    <div class="form-group">
                                        @Html.LabelFor(model => model.CanFiscalize, Loc.FiscalizeInvoices, new { @class = "col-md-3", title = Loc.FiscalizeInvoices })
                                        <div class="col-md-9">
                                            <input value="@Model.FiscalType" id="FiscalTypeSaved" hidden />
                                            @if ((Model.SetOf == "N" && (Model.Type == "I" || Model.Type == "P")) || (Model.SetOf == "F" && Model.TypeOfDoc == "A" && Model.Type == "I"))
                                            {
                                                @Html.DropDownListFor(model => model.FiscalType,
                                                    new SelectList(new List<dynamic> {
                                                        new { Value = PantheonRA.BackOffice.Enums.FiscalTypeRS.WithoutFiscalization, Text = Loc.WithoutFiscalization },
                                                        new { Value = PantheonRA.BackOffice.Enums.FiscalTypeRS.ProductionEnvironment, Text = Loc.ProductionEnvironment }
                                                    }, "Value", "Text"), "",
                                                    new { @class = "form-control custom-select" })
                                            }
                                            else
                                            {
                                                @Html.DropDownListFor(model => model.FiscalType,
                                                    new SelectList(new List<dynamic> {
                                                        new { Value = PantheonRA.BackOffice.Enums.FiscalTypeRS.WithoutFiscalization, Text = Loc.WithoutFiscalization },
                                                        new { Value = PantheonRA.BackOffice.Enums.FiscalTypeRS.TestEnvironment, Text = Loc.TestEnvironment },
                                                        new { Value = PantheonRA.BackOffice.Enums.FiscalTypeRS.ProductionEnvironment, Text = Loc.ProductionEnvironment }
                                                    }, "Value", "Text"), "",
                                                    new { @class = "form-control custom-select" })
                                            }
                                            @Html.ValidationMessageFor(model => model.FiscalType, "", new { @class = "text-danger", @id = "FiscalType-validation" })
                                        </div>
                                    </div>
                                }

                                @if (PantheonRA.BackOffice.CurrentUser.DatabaseLocalization == Localization.Code.HR)
                                {
                                    <div class="form-group">
                                        @Html.LabelFor(model => model.FiscAll, Loc.FiscalizeAllDocuments, new { @class = "col-md-3" })
                                        <div class="col-md-9">
                                            @Html.CheckBoxFor(model => model.FiscAll, new { @class = "form-control js-switch js-switch-small", autocomplete = "off" })
                                            @Html.ValidationMessageFor(model => model.FiscAll, "", new { @class = "text-danger block", @id = "FiscAll-validation" })
                                        </div>
                                    </div>
                                }

                                @if (!isInFiscalPrinterLocalization && PantheonRA.BackOffice.CurrentUser.DatabaseLocalization != Localization.Code.RS)
                                {
                                    <div id="fiscalData">
                                        <div class="form-group">
                                            @Html.LabelFor(model => model.FiscalWorkplaceId, Loc.CompanyUnit, new { @class = "col-md-3 control-label" })
                                            <div class="col-md-9">
                                                @Html.DropDownListFor(model => model.FiscalWorkplaceId,
                                                  new SelectList(ViewBag.FiscalWorkPlaces, "Value", "Text"), "",
                                                  new { @class = "form-control custom-select" })
                                                @Html.ValidationMessageFor(model => model.FiscalWorkplaceId, "", new { @class = "text-danger", @id = "FiscalWorkplaceId-validation" })
                                            </div>
                                        </div>

                                        @if (PantheonRA.BackOffice.CurrentUser.DatabaseLocalization != Localization.Code.ME)
                                        {
                                            <div class="form-group">
                                                @Html.LabelFor(model => model.FiscalDevice, Loc.DeviceTag, new { @class = "col-md-3 control-label" })
                                                <div class="col-md-9">
                                                    @Html.TextBoxFor(model => model.FiscalDevice,
                                                         new { @class = "form-control", autocomplete = "off", placeholder = Loc.DeviceTag })
                                                    @Html.ValidationMessageFor(model => model.FiscalDevice, "", new { @class = "text-danger", @id = "FiscalDevice-validation" })
                                                </div>
                                            </div>
                                        }
                                        @Html.HiddenFor(model => model.UseFiscalRounding)

                                        @if (PantheonRA.BackOffice.CurrentUser.DatabaseLocalization == Localization.Code.HR)
                                        {
                                            <div class="form-group">
                                                @Html.LabelFor(model => model.DocTypeTipFiscalization, Loc.BPTipDocType, new { @class = "col-md-3" })
                                                <div class="col-md-9">
                                                    @Html.DropDownListFor(model => model.DocTypeTipFiscalization, 
                                                        new SelectList(ViewBag.TipFiscalizationDocTypes != null ? ViewBag.TipFiscalizationDocTypes : new List<string>(), "Id", "Name"), 
                                                        "", new { @class = "form-control custom-select" })
                                                    @Html.ValidationMessageFor(model => model.DocTypeTipFiscalization, "", new { @class = "text-danger block", @id = "DocTypeTipFiscalization-validation" })
                                                </div>
                                            </div>
                                        }
                                    </div>
                                }
                                else
                                {
                                    @Html.HiddenFor(model => model.FiscalWorkplaceId)
                                    @Html.HiddenFor(model => model.FiscalDevice)

                                    if (!PantheonRA.BackOffice.CurrentUser.IsInServerFiscalization)
                                    {
                                        <div id="fiscalData">
                                            <div class="form-group">
                                                @Html.LabelFor(model => model.UseFiscalRounding, Loc.FiscalPrinterRounding, new { @class = "col-md-3" })
                                                <div class="col-md-9">
                                                    @Html.CheckBoxFor(model => model.UseFiscalRounding, new { @class = "form-control js-switch js-switch-small", autocomplete = "off" })
                                                    @Html.ValidationMessageFor(model => model.UseFiscalRounding, "", new { @class = "text-danger block", @id = "UseFiscalRounding-validation" })
                                                </div>
                                            </div>
                                        </div>
                                    }
                                    else
                                    {
                                        @Html.HiddenFor(model => model.CanFiscalize)
                                        @Html.HiddenFor(model => model.FiscalType)
                                        @Html.HiddenFor(model => model.UseFiscalRounding)
                                        @Html.HiddenFor(model => model.FiscalDevice)
                                        @Html.HiddenFor(model => model.FiscalWorkplaceId)
                                    }

                                    if (!PantheonRA.BackOffice.CurrentUser.IsInServerFiscalization)
                                    {
                                        if (PantheonRA.BackOffice.CurrentUser.DatabaseLocalization != Localization.Code.MK)
                                        {
                                            <h3 class="m-b-md m-t-md">@Loc.Note</h3>
                                            <div class="form-group">
                                                @Html.LabelFor(model => model.FiscalNote1, Loc.UnfiscalizedTextBeforeInvoice, new { @class = "col-md-3" })
                                                <div class="col-md-9">
                                                    @Html.TextAreaFor(model => model.FiscalNote1, new { @class = "form-control", autocomplete = "off", rows = "4" })
                                                    @Html.ValidationMessageFor(model => model.FiscalNote1, "", new { @class = "text-danger block", @id = "FiscalNote1-validation" })
                                                </div>
                                            </div>

                                            <div class="form-group">
                                                @Html.LabelFor(model => model.FiscalNote2, Loc.UnfiscalizedTextAfterInvoice, new { @class = "col-md-3" })
                                                <div class="col-md-9">
                                                    @Html.TextAreaFor(model => model.FiscalNote2, new { @class = "form-control", autocomplete = "off", rows = "4" })
                                                    @Html.ValidationMessageFor(model => model.FiscalNote2, "", new { @class = "text-danger block", @id = "FiscalNote2-validation" })
                                                </div>
                                            </div>
                                        }
                                        else
                                        {
                                            @Html.HiddenFor(model => model.FiscalNote1)
                                            @Html.HiddenFor(model => model.FiscalNote2)
                                        }
                                    }
                                    else
                                    {
                                        @Html.HiddenFor(model => model.FiscalNote1)
                                        @Html.HiddenFor(model => model.FiscalNote2)

                                        <div class="form-group">
                                            <label class="col-md-3 control-label" title="@Loc.Links">@Loc.Links</label>
                                            <div class="col-md-9">
                                                <div class="input-group">
                                                    <input disabled class="form-control" value="@Model.FiscalServerByDoc" title="@Model.FiscalServerByDoc, @Model.FiscalTaxServerByDoc, @Model.FiscalCheckConnectionServerByDoc" autocomplete="off" onclick="$(this).closest('.input-group').find('button').trigger('click'); $(this).blur();" />
                                                    @Html.HiddenFor(model => model.FiscalServerByDoc)
                                                    @Html.HiddenFor(model => model.FiscalCheckConnectionServerByDoc)
                                                    @Html.HiddenFor(model => model.FiscalTaxServerByDoc)
                                                    <span class="input-group-addon">
                                                        <button type="button" class="btn btn-ghost btn-xs padding-bottom-none" onclick="openLPFRServerDataModal($('#FiscalServerByDoc'), $('#FiscalTaxServerByDoc'), $('#FiscalCheckConnectionServerByDoc'), '@Loc.Links', ['@Loc.TypeShort', '@Loc.Link'], ['@Loc.FiscalServer', '@Loc.TaxServer', '@Loc.CheckConnectionServer']);">
                                                            <i class="fas fa-pencil-alt"></i>
                                                        </button>
                                                    </span>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            @Html.LabelFor(model => model.IsLPFREnabled, Loc.IsLPFR, new { @class = "col-md-3" })
                                            <div class="col-md-9">
                                                @Html.CheckBoxFor(model => model.IsLPFREnabled, new { @class = "form-control js-switch js-switch-small", autocomplete = "off" })
                                                @Html.ValidationMessageFor(model => model.IsLPFREnabled, "", new { @class = "text-danger block", @id = "IsLPFREnabled-validation" })
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            @Html.LabelFor(model => model.AnQIDCert, Loc.Certificate, new { @class = "col-md-3 control-label" })
                                            <div class="col-md-9">
                                                @Html.HiddenFor(model => model.AnQIDCert)
                                                <input class="form-control typeahead_3" id="certificateInputView" value="@Model.CertSerialNumber" autocomplete="off" placeholder="@Loc.Search" />
                                            </div>
                                        </div>
                                    }
                                }
                            </div>
                        }
                        else
                        {
                            @Html.HiddenFor(model => model.CanFiscalize)
                        }

                        @if (isTravelOrder)
                        {
                            <div class="col-sm-6 col-lg-6">
                                <h3 class="m-b-md m-t-md">@Loc.Costs</h3>
                                <table id="travelorders-expenses"
                                       data-grid-id="travelorders-expense-types"
                                       class="table table-condensed table-bordered showhidecolumns">
                                    <thead class="module-bg">
                                        <tr>
                                            <th data-column-id="Hidden1" class="hidden"></th>
                                            <th data-column-id="Active" width="5%">@Loc.ActiveShort</th>
                                            <th data-column-id="Type" width="10%">@Loc.CostTypes</th>
                                            <th data-column-id="Name" width="20%">@Loc.Name</th>
                                            <th data-column-id="NotForPayout" width="20%">@Loc.NotForPayout</th>
                                            <th data-column-id="EarningType" data-default-hidden="true" width="20%">@Loc.SalaryTypeShort</th>
                                            <th data-column-id="Account" data-default-hidden="true" width="20%">@Loc.Account</th>
                                            <th data-column-id="AddDelete" width="5%" data-sortable="false"></th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr id="doctype-expenses-new-row">
                                            <td class="hidden">
                                                <input id="DocType-@newExpenseRowNum"
                                                       value="@Model.Id" />
                                            </td>
                                            <td>
                                                @Html.CheckBox("Active-" + @newExpenseRowNum,
                                                            new
                                                                 {
                                                                     @class = "form-control custom-checkbox",
                                                                id = "Active-" + @newExpenseRowNum,
                                                                autocomplete = "off"
                                                                 })
                                            </td>
                                            <td>
                                                <input id="Type-@newExpenseRowNum"
                                                       type="text"
                                                       class="form-control contact-data-input"
                                                       onclick="setNewCostTypeNumber()" />
                                            </td>
                                            <td>
                                                <input id="Name-@newExpenseRowNum"
                                                       type="text"
                                                       class="form-control contact-data-input" />
                                            </td>
                                            <td>
                                                @Html.CheckBox("NotForPay-" + @newExpenseRowNum,
                                                            new
                                                                 {
                                                                     @class = "form-control custom-checkbox",
                                                                id = "NotForPay-" + @newExpenseRowNum,
                                                                autocomplete = "off"
                                                                 })
                                            </td>
                                            <td>
                                                <div class="contact-data-selects select2HideColumns">
                                                    <select id="EarningType-@newExpenseRowNum"
                                                            data-placeholder="@Loc.SalaryTypeShort"
                                                            class="form-control select2withAPI contact-data-input"
                                                            data-column-names="@Loc.Code,@Loc.Name"
                                                            data-url=@Url.Action("GetSalaryTypes", "SetCalendarEntryTypes")
                                                            data-allow-clear="true"
                                                            data-first-column-only="true"
                                                            data-search-width="350"
                                                            data-mobile-width="200"
                                                            data-bootstrap-columns="col-md-3,col-md-9"></select>
                                                </div>
                                            </td>
                                            <td>
                                                <div class="contact-data-selects select2HideColumns">
                                                    <select id="Account-@newExpenseRowNum"
                                                            data-placeholder="@Loc.Account"
                                                            class="form-control select2withAPI contact-data-input"
                                                            data-column-names="@Loc.Account,@Loc.Name"
                                                            data-url=@Url.Action("SearchAccounts", "AccountCard")
                                                            data-allow-clear="true"
                                                            data-first-column-only="true"
                                                            data-search-width="350"
                                                            data-mobile-width="200"
                                                            data-bootstrap-columns="col-md-3,col-md-9"></select>
                                                </div>
                                            </td>
                                            <td id="btn-col" class="add-btn-td">
                                                <a class="btn btn-success"
                                                   title="@Loc.Add"
                                                   onclick="addNewExpenseType()"
                                                   href="#">
                                                    <i class="fa fa-plus"></i>
                                                </a>
                                            </td>
                                        </tr>
                                        @if (Model.Expenses != null)
                                        {
                                            var index = 0;
                                            foreach (var expense in Model.Expenses)
                                            {
                                                var expensesNameFormat = "Expenses[" + index + "].{0}";
                                                var hideOnDefault = index == 0 ? "hidden" : string.Empty;
                                                <tr id="doctype-expenses-row-@index" class="doctype-expenses">
                                                    <td class="hidden">
                                                        <input id="AnQId-@index"
                                                               name="@string.Format(expensesNameFormat, "AnQId")"
                                                               value="@expense.AnQId">
                                                        <input id="DocType-@index"
                                                               name="@string.Format(expensesNameFormat, "DocType")"
                                                               value="@expense.DocType">
                                                    </td>
                                                    <td>
                                                        @Html.CheckBoxFor(model => expense.Active,
                                                            new
                                                                 {
                                                                     @class = "form-control custom-checkbox",
                                                                id = "Active-" + index,
                                                                Name = string.Format(expensesNameFormat, "Active"),
                                                                autocomplete = "off"
                                                                 })
                                                        @Html.ValidationMessageFor(model => expense.Active, "", new { @class = "text-danger block", @id = "Active-validation" })
                                                    </td>
                                                    <td>
                                                        <input id="Type-@index"
                                                               name="@string.Format(expensesNameFormat, "Type")"
                                                               type="text"
                                                               class="form-control contact-data-input"
                                                               value="@expense.Type" />
                                                    </td>
                                                    <td>
                                                        <input id="Name-@index"
                                                               name="@string.Format(expensesNameFormat, "Name")"
                                                               type="text"
                                                               class="form-control contact-data-input"
                                                               value="@expense.Name" />
                                                    </td>
                                                    <td>
                                                        @Html.CheckBoxFor(model => expense.NotForPay,
                                                            new
                                                                 {
                                                                     @class = "form-control custom-checkbox",
                                                                id = "NotForPay-" + index,
                                                                Name = string.Format(expensesNameFormat, "NotForPay"),
                                                                autocomplete = "off"
                                                                 })
                                                        @Html.ValidationMessageFor(model => expense.NotForPay, "", new { @class = "text-danger block", @id = "NotForPay-validation" })
                                                    </td>
                                                    <td>
                                                        <div class="contact-data-selects select2HideColumns">
                                                            <select id="EarningType-@index"
                                                                    name="@string.Format(expensesNameFormat, "EarningType")"
                                                                    data-placeholder="@Loc.SalaryTypeShort"
                                                                    class="form-control select2withAPI contact-data-input"
                                                                    data-column-names="@Loc.Code,@Loc.Name"
                                                                    data-url=@Url.Action("GetSalaryTypes", "SetCalendarEntryTypes")
                                                                    data-allow-clear="true"
                                                                    data-search-width="350"
                                                                    data-mobile-width="200"
                                                                    data-first-column-only="true"
                                                                    data-bootstrap-columns="col-md-3,col-md-9">
                                                                <option selected="@expense.EarningType">@expense.EarningType</option>
                                                            </select>
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div class="contact-data-selects select2HideColumns">
                                                            <select id="Account-@index"
                                                                    name="@string.Format(expensesNameFormat, "Account")"
                                                                    data-placeholder="@Loc.Account"
                                                                    class="form-control select2withAPI contact-data-input"
                                                                    data-column-names="@Loc.Account,@Loc.Name"
                                                                    data-url=@Url.Action("SearchAccounts", "AccountCard")
                                                                    data-allow-clear="true"
                                                                    data-search-width="350"
                                                                    data-mobile-width="200"
                                                                    data-first-column-only="true"
                                                                    data-bootstrap-columns="col-md-3,col-md-9">
                                                                <option selected="@expense.Account">@expense.Account</option>
                                                            </select>
                                                        </div>
                                                    </td>
                                                    <td class="@hideOnDefault">
                                                        <a class="a-outline"
                                                           title="@Loc.Delete"
                                                           onclick="deleteExpenseType('@index')">
                                                            <i class="far fa-trash-alt"></i>
                                                        </a>
                                                    </td>
                                                </tr>

                                                index++;
                                            }

                                        }
                                    </tbody>
                                </table>
                            </div>
                        }
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<input type="hidden" id="printSettingsUrl" value="@Url.Action("GetPrintSettings", "DocumentType", new { docType = Model.Id })" />
<input type="hidden" id="changePrintSettingsUrl" value="@Url.Action("ChangePrintSettings", "DocumentType")" />
<input type="hidden" id="ErrorWhileSavingSettingsLoc" value="@Loc.ErrorWhileSavingSettings" />
<input type="hidden" id="ErrorLoc" value="@Loc.Error" />
<input type="hidden" id="YesLoc" value="@Loc.Yes" />
<input type="hidden" id="NoLoc" value="@Loc.No" />
<input type="hidden" id="OkLoc" value="@Loc.OK" />
<input type="hidden" id="ConfirmLoc" value="@Loc.Confirm" />
<input type="hidden" id="WorkPlaceFiscaliteRequiredWorkplaceLoc" value="@Loc.WorkPlaceFiscaliteRequiredWorkplace" />
<input type="hidden" id="FiscalWorkplaceAndDeviceCombinationAlreadyExistsLoc" value="@Loc.FiscalWorkplaceAndDeviceCombinationAlreadyExists" />
<input type="hidden" id="checkFiscalWorkplaceUrl" value="@Url.Action("CheckFiscalWorkplace", "DocumentType")" />
<input type="hidden" id="canChangeIsEvidence" value="@Url.Action("CanChangeIsEvidence", "DocumentType")" />
<input type="hidden" id="docTypeHasFiscalDocsUrl" value="@Url.Action("DocTypeHasFiscalDocs", "DocumentType")" />
<input type="hidden" id="documentTypeRetail" value="@DocumentTypeAcType.Retail" />
<input type="hidden" id="documentTypeWholesale" value="@DocumentTypeAcType.Wholesale" />
<input type="hidden" id="thereAreAlreadyDocumentsForThisDocumentLoc" value="@Loc.ThereAreAlreadyDocumentsForThisDocumentTypeChangeNotPossible" />
<input type="hidden" id="cannotChangeCanFiscalizeSettingLoc" value="@Loc.CannotChangeCanFiscalizeSetting" />


@section pageScripts{
    @Scripts.Render("~/bundles/admin")
<script>
    $(document).ready(function () {
        initializeDocumentTypeEdit('@isInFiscalPrinterLocalization' === '@Boolean.TrueString', '@PantheonRA.BackOffice.CurrentUser.Localization' !== '@Localization.Code.MK' && '@PantheonRA.BackOffice.CurrentUser.Localization' !== '@Localization.Code.BA' && '@PantheonRA.BackOffice.CurrentUser.Localization' !== '@Localization.Code.BG');
            $.ajax({
                url: "@System.Configuration.ConfigurationManager.AppSettings.Get("FiscalizationLocalApiUrl")/getMachineName",
                type: 'GET',
                cache: false,
                headers: {
                    'Content-Type': 'application/json',
                    'Authorization': 'Basic QUQ6YTIxODQwNzZDRTczNzlEOUZERkVEYXRhTGFiMTIz'
                }
            }).done(function (data) {
                if (data && data.machineName) {
                    $("#MachineName").val(data.machineName);
                    $.ajax({
                        url: '@Url.Action("GetDefaultFiscalDevice", "DocumentType")?docType=@Model.Id&machineName=' + data.machineName,
                        type: 'GET',
                        cache: false
                    }).done(function (data) {
                        if (data && data.defaultFiscalDevice) {
                            $("#DefaultFiscalDevice").val(data.defaultFiscalDevice.AnQid);
                        }
                        $("#DefaultFiscalDevice").prop("disabled", false);
                    }).fail(function () {
                        $("#DefaultFiscalDevice").prop("disabled", false);
                    });
                } else {
                    $("#DefaultFiscalDevice").prop("disabled", false);
                }
            }).fail(function () {
                $("#DefaultFiscalDevice").prop("disabled", false);
            });

            let preSelectedSerialNumbers = $("#PreSelectedSerialNumbers").val();
            if (preSelectedSerialNumbers)
                $("#SelectedSerialNumbers").selectpicker('val', preSelectedSerialNumbers.split(","));

            initializeCertificatesTypeahead('@Url.Action("GetCertificatesTypeahead", "Certificate")', $('#certificateInputView'), $("#AnQIDCert"), function (certificate) { });

            $("#IsOrderCalendar").on("change", function () {
                $(this)[0].checked ? $("#DocTypeForPOS-container").removeClass("hidden") : $("#DocTypeForPOS-container").addClass("hidden");
            });

            $("#saveButton").on("click", function () {
                if ($("#IsOrderCalendar")[0] && !$("#IsOrderCalendar")[0].checked) {
                    $("#DocTypeForPOS").val("");
                }

                $("#saveButton i").addClass("fa-spin fa-spinner").removeClass("fa-save");
                var formData = $("#mainForm").serializeArray();

                var url = "@Url.Action("Create", "DocumentType")";
                if ($("#IsEdit").val() === "True")
                    url = "@Url.Action("Edit", "DocumentType")";

                $.post(url, formData)
                    .done(function (response) {
                        if (response && response.Success === true)
                            location.href = '@Url.Action("Index", "DocumentType")?search=' + response.Id;
                        else {
                            $("#saveButton i").removeClass("fa-spin fa-spinner").addClass("fa-save");

                            if (!response.Success) {
                                clearValidationErrors();

                                if (response.errors)
                                    displayResponseValidationErrors(response);
                            }
                        }
                    });
            });
        });
</script>
}

<style>
    button[data-id="SelectedSerialNumbers"] {
        border-bottom: none !important;
    }
</style>
