@using PantheonRA.BackOffice.Models
@using PantheonRA.BackOffice.Enums
@model PantheonRA.BackOffice.Models.WholesaleGridFilterModel
@{
    ViewBag.Title = Loc.IssuedBillsSummary;
}

<div class="wrapper wrapper-content">
    <div class="tabs-container">
        @Html.Partial("_CashRegisterTabNavigation")
        <div class="tab-content">
            <div class="row buttons-tabbed">
                @Html.Partial("_GridButtons", new GridButtonsViewModel {
                    AddButton = new PantheonRA.BackOffice.Models.FormButton{
                        Url = Url.Action("Index", "CashRegister"),
                        Icon = "fa fa-plus",
                        Text = Loc.New
                    }
                })
            </div>

            <div class="row document-head">
                @Html.HiddenFor(model => model.DefaultDecimalPlacesPrice)
                @Html.HiddenFor(model => model.DefaultDecimalPlacesQuantity)
                @Html.HiddenFor(model => model.DefaultDecimalPlacesValue)
                <div class="col-md-2 col-xs-4">
                    @Html.Partial("~/Views/Reports/_IssuedBillsTabNavigation.cshtml", new IssuedBillsTabModel() { Type = IssuedBillsTabType.Summary, Author = AuthorType.POS })
                </div>

                <div class="col-md-3 col-xs-6">
                    <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-lg-2 col-md-3 col-xs-6">
                    <div class="form-group">
                        @Html.LabelFor(model => model.DocType, Loc.DocType, new { @class = "control-label" })
                        @Html.DropDownListFor(model => model.DocType, new SelectList(ViewBag.DocumentTypes != null ? ViewBag.DocumentTypes : new List<string>(), "Id", "Value"), Loc.All,
                            HtmlAttributesHelper.CreateInputAttributes("form-control selectpicker", "DocType", false, Loc.DocTypeShort, true, new { @multiple = "multiple", @title = Loc.Select }))
                        @Html.ValidationMessageFor(model => model.DocType, "", new { @class = "text-danger" })
                    </div>
                </div>

                <div class="col-lg-1 col-xs-6">
                    <div class="form-group">
                        <label>@Loc.Currency</label>
                        @Html.DropDownListFor(model => model.Currency, new SelectList(ViewBag.CurrencyTypes, "Value", "Text", ""), Loc.Currency,
                            HtmlAttributesHelper.CreateInputAttributes("form-control custom-select", "Currency", false))
                    </div>
                </div>

                <div class="col-md-2 col-xs-6 dateFilter">
                    <div class="form-group">
                        <label class="control-label">@Loc.DateFrom</label>
                        <div class="input-group">
                            <span class="input-group-addon"><i class="far fa-calendar alt"></i></span>
                            <input class="form-control datepicker" id="Filter_DateFrom" name="Filter.DateFrom" type="text" value="@DateTime.Now.Date.AddMonths(-1).ToString(Loc.DateFormat)">
                        </div>
                    </div>
                </div>
                <div class="col-md-2 col-xs-6 dateFilter">
                    <div class="form-group">
                        <label class="control-label">@Loc.DateTo</label>
                        <div class="input-group">
                            <span class="input-group-addon"><i class="far fa-calendar alt"></i></span>
                            <input class="form-control datepicker" id="Filter_DateTo" name="Filter.DateTo" type="text" value="@DateTime.Now.Date.ToString(Loc.DateFormat)">
                        </div>
                    </div>
                </div>
            </div>

            <div class="project-list">
                <div class="document-list">
                    <table id="mainGrid" data-grid-id="wholesale" data-url="@Url.Action("WholesaleList", "Wholesale")" data-height="calc(100vh - 330px)" class="list-table">
                        <thead>
                            <tr>
                                <th width="3%" data-function="openPdfPreview('@Url.Action("PAASPrintByAcKeyAndType", "Move")?fiscalize=false&preview=true&acKey={0}&type={1}')"></th>
                                <th data-url="@Url.Action("Index", "CashRegister")?returnUrl=@(Url.Action("IssuedBillsSum", "CashRegister"))&acKey=">@Loc.Number</th>
                                <th width="12%" data-url="@Url.Action("Edit", "Subjects")?returnUrl=@(Url.Action("IssuedBillsSum", "CashRegister"))&id=">@Loc.Buyer</th>
                                <th width="8%" class="dt-head-right">@Loc.PriceWithoutTax</th>
                                <th width="10%" class="dt-head-right">@Loc.PriceWithTax</th>
                                <th width="6%">@Loc.ServiceDateShort</th>
                                <th width="6%">@Loc.InvoiceDateShort</th>
                                <th width="6%">@Loc.DateDue</th>
                                <th>@Loc.Order</th>
                                <th>@Loc.OrderForm</th>
                                <th>@Loc.BuyerType</th>
                                <th>@Loc.Status</th>
                            </tr>
                        </thead>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>

@Html.Partial("~/Views/Shared/Components/_sidePanel.cshtml", new PantheonRA.BackOffice.Models.SidePanelViewModel { Id = "pdfPanel" })
@Html.Partial("~/Views/Shared/Components/_PreviewPrintMenuButton.cshtml", new PantheonRA.BackOffice.Models.PreviewReportTreeViewModel { ReportTree = Model.ReportTree })

@section pageScripts{
    @Scripts.Render("~/bundles/bills")
    <script>
        $(document).ready(function () {
            initializeIssuedBillsSum('@PantheonRA.BackOffice.Enums.ItemsDisplayFilterType.CustomDate',
                '@PantheonRA.WebApi.Contracts.Enums.CashRegType.ReceivedBills',
                { Z: '@Loc.IsTaxCommitedShort', K: '@Loc.FinalBuyer', I: '@Loc.ExportSale', E: '@Loc.ExportSaleEU', C: '@Loc.WayOfSaleDiplomaticConsulate' });
        });
    </script>
}
