@using PantheonRA.BackOffice.Models
@model PantheonRA.BackOffice.Models.TaxRatesFilterModel
@{
    ViewBag.Title = Loc.Taxes;
    var isLocRS = (PantheonRA.BackOffice.CurrentUser.Localization == PAW.Contracts.Enums.Localization.Code.RS);
}

<div class="wrapper wrapper-content">
    <div class="tabs-container">
        @Html.Partial("~/Views/Products/_CodeListTabNavigation.cshtml")
        <div class="tab-content">
            <div class="row buttons-tabbed">
                <button type="button" id="printButton" class="btn btn-success pull-right" onclick="printTax('036')">
                    <i class="far fa-print printButton-icon print-loader-icon m-r-xs" title="@Loc.Print"></i>@Loc.Print
                </button>

                @if (isLocRS)
                {
                    <button type="button" class="btn btn-success btn-outline pull-right" onclick="updateTaxRates(this)"
                            title="@(Loc.TaxRatesLastUpdate + ": " + (Model.TaxRateLastUpdate.HasValue ? Model.TaxRateLastUpdate.Value.ToString(Loc.DateTimeFormat) : "/"))">
                        <i class="fas fa-paper-plane m-r-xs"></i> @Loc.UpdateTaxRates
                    </button>
                }

                @Html.Partial("_GridButtons", new GridButtonsViewModel
                {
                    AddButton = new PantheonRA.BackOffice.Models.FormButton
                    {
                        Url = Url.Action("Create", "Taxes"),
                        Icon = "fa fa-plus",
                        Text = Loc.NewTax
                    }
                })
            </div>

            @Html.HiddenFor(model => model.DefaultDecimalPlacesPrice)
            @Html.HiddenFor(model => model.DefaultDecimalPlacesQuantity)
            @Html.HiddenFor(model => model.DefaultDecimalPlacesValue)
            <div class="row document-head">
                <div class="col-md-3">
                    <div class="form-group">
                        <label class="control-label">@Loc.SearchFilter</label>
                        @Html.TextBoxFor(model => model.Keywords, new { @id = "Keywords", @class = "form-control search-input", @placeholder = Loc.Search, autocomplete = "off" })
                    </div>
                </div>
                <div class="col-md-2">
                    <div class="form-group">
                        <label class="control-label">@Loc.ShowActive</label>
                        <select id="Status" name="Status" class="form-control search-addon custom-select">
                            <option value="">@Loc.All</option>
                            <option value="T" selected>@Loc.ActiveStatus</option>
                            <option value="F">@Loc.InactiveStatus</option>
                        </select>
                    </div>
                </div>
            </div>

            <div class="project-list">
                <div class="document-list document-list-no-footer">
                    <table id="mainGridTaxRates" data-grid-id="taxes" data-url="@Url.Action("_TaxList", "Taxes")" class="list-table">
                        <thead>
                            <tr>
                                <th data-url="@Url.Action("Edit", "Taxes")?id=">@Loc.TaxCodeFull</th>
                                <th data-url="@Url.Action("Edit", "Taxes")?id=">@Loc.TaxDescription</th>
                                <th data-visible="@(isLocRS ? true : false)">@Loc.FiscalNumber</th>
                                <th data-visible="@(isLocRS ? true : false)">@Loc.FiscalizationName</th>
                                <th>% @Loc.GridTax</th>
                                <th data-visible="@(isLocRS ? true : false)">@Loc.EDocument</th>
                                <th data-visible="@(isLocRS ? true : false)">@Loc.Text</th>
                            </tr>
                        </thead>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>

<input type="hidden" id="UpdateTaxRatesUrl" value="@Url.Action("UpdateTaxRates", "Taxes")" />
<input type="hidden" id="OkLoc" value="@Loc.OK" />
<input type="hidden" id="LoadingDocumentLoc" value="@Loc.LoadingDocument" />
<input type="hidden" id="ConfirmLoc" value="@Loc.Confirm" />
<input type="hidden" id="TaxRatesUpdateSuccessfulLoc" value="@Loc.TaxRatesUpdateSuccessful" />
<input type="hidden" id="StandardTaxRateLoc" value="@Loc.StandardTaxRate" />
<input type="hidden" id="ExemptFromVATLoc" value="@Loc.ExemptFromVAT" />
<input type="hidden" id="TheSubjectIsNotInTheVATSystemLoc" value="@Loc.TheSubjectIsNotInTheVATSystem" />
<input type="hidden" id="ZeroVATRateLoc" value="@Loc.ZeroVATRate" />
<input type="hidden" id="ExemptFromVATDueToExportLoc" value="@Loc.ExemptFromVATDueToExport" />
<input type="hidden" id="TransferOfTaxLiabilityLoc" value="@Loc.TransferOfTaxLiability" />
<input type="hidden" id="ExemptionFromVATLoc" value="@Loc.ExemptionFromVAT" />
<input type="hidden" id="TaxPrintUrl" value="@Url.Action("TaxPrint", "Taxes")" />

@section pageScripts{
    @Scripts.Render("~/bundles/product")
    <script>
        $(document).ready(function () {
            initializeTaxes();
        });
    </script>
}