@using PAW.Contracts.Enums;
@model PantheonRA.BackOffice.Models.JournalListViewModel
@{
    ViewBag.Title = Loc.CashRegisterJournalList;
    Html.RenderPartial("_Breadcrumb", new PantheonRA.BackOffice.Models.BreadcrumbViewModel());
}

<div class="wrapper wrapper-content">
    <div class="tabs-container">
        @Html.Partial("_JournalTabNavigation")

        <div class="row buttons-tabbed">
            <a href="@Url.Action("Index", "CashRegister")" class="btn btn-success pull-right"><span class="bold">@Loc.Back</span></a>
            <button id="createButton" class="btn btn-primary pull-right">
                <i class="fa fa-plus" title="@Loc.CreateJournal"></i><span class="bold hidden-xs m-l-xs">@Loc.CreateJournal</span>
            </button>
        </div>

        <div class="row document-head">
            @Html.HiddenFor(m => m.PreventCreateJournal)
            <div class="col-md-2 col-xs-6">
                <div class="form-group">
                    @Html.LabelFor(model => model.Filter.DateTo, Loc.ToDate)
                    @Html.TextBoxFor(m => m.Filter.DateTo, "{0:dd.MM.yyyy}", new { @class = "form-control datepicker", @autocomplete = "off" })
                </div>
            </div>

            <div class="col-md-3 col-xs-6">
                <div class="form-group">
                    @Html.LabelFor(model => model.Filter.AcKeyTo, Loc.ToDocument)
                    @Html.TextBoxFor(m => m.Filter.AcKeyTo, new { @class = "form-control", @autocomplete = "off" })
                </div>
            </div>

            <div class="col-md-3 col-xs-12">
                <div class="form-group">
                    @Html.LabelFor(model => model.Filter.DocType, Loc.DocType, new { @class = "control-label" })
                    @Html.DropDownListFor(m => m.Filter.DocType, new SelectList(ViewBag.DocumentTypes != null ? ViewBag.DocumentTypes : new List<string>(), "Id", "Value"), null,
                        HtmlAttributesHelper.CreateInputAttributes("form-control selectpicker localStorageFilter", "DocType", false, Loc.DocTypeShort, true, new { @title = Loc.Select }))
                </div>
            </div>
        </div>

        <div class="project-list">
            <div class="document-list">
                <table id="grid-data" data-grid-id="journal" data-url="@Url.Action("ListData", "Journal")" class="list-table">
                    <thead>
                        <tr>
                            <th data-url="@Url.Action("PrintPreview", "CashRegister")?returnUrl=@(Url.Encode("/Reports#ReceivedCashDocuments"))&id=">@Loc.DocumentKey</th>
                            <th>@Loc.NoteDate</th>
                            <th>@Loc.Customer</th>
                            <th class="dt-head-right">@Loc.Amount</th>
                            <th>@Loc.User</th>
                        </tr>
                    </thead>
                </table>
            </div>

            <div class="row document-footer document-footer-sm">
                <div class="col-xs-9">
                    <div class="form-group">
                        <span class="pull-left">
                            <strong>@Loc.Total.ToUpper() <span id="grid-data-start-items"></span> @Loc.To.ToLower() <span id="grid-data-total-items"></span>: </strong>
                            <b id="grid-data-total-items"></b>
                        </span>
                    </div>
                </div>
                <div class="col-xs-3 document-head-highlight-input">
                    <div class="form-group text-right">
                        <span>@Loc.Amount:</span> <label id="grid-data-total-sum"></label>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>



<input type="hidden" id="JournalUrl" value="@Url.Action("ReceivedCashDocuments", "CashRegister")" />
<input type="hidden" id="CreateJournalUrl" value="@Url.Action("Create", "Journal")" />
<input type="hidden" id="GetPosSettingsUrl" value="@Url.Action("GetPosSettings", "Journal")" />
<input type="hidden" value="@Loc.CreateCashRegJournalError" id="createCashRegJournalError" />
<input type="hidden" value="@Loc.GeneralError" id="cashRegJournalGeneralError" />
<input type="hidden" value="@Loc.NoEligibleJournalInvoices" id="cashRegJournalNoEligibleInvoicesError" />
<input type="hidden" value="@Loc.OK" id="okLoc" />

@section pageScripts{
    @Scripts.Render("~/bundles/journals")
    <script>
        if ('@Localization.IsInFiscalPrinterLocalization(PantheonRA.BackOffice.CurrentUser.DatabaseLocalization, PantheonRA.BackOffice.CurrentUser.IsInServerFiscalization)' === '@Boolean.TrueString') {
            getLocalMachineName('@System.Configuration.ConfigurationManager.AppSettings.Get("FiscalizationLocalApiUrl")')
        }
        $(document).ready(function () {
        let localization = {
            zReportTitle: '@Loc.ZReport',
            zReportSuccessMessage: '@Loc.ZReportSuccessful'
        };
        initializeJournal(localization, '@Localization.IsInFiscalPrinterLocalization(PantheonRA.BackOffice.CurrentUser.DatabaseLocalization, PantheonRA.BackOffice.CurrentUser.IsInServerFiscalization)' === '@Boolean.TrueString',
        '@(Url.Action("Index", "CashRegister") == "/" ? "/CashRegister" : Url.Action("Index", "CashRegister"))', '@System.Configuration.ConfigurationManager.AppSettings.Get("FiscalizationLocalApiUrl")');
});
    </script>
}