
@model PantheonRA.BackOffice.Models.CashTransactionsViewModel
@using PantheonRA.BackOffice.Enums

<div class="row document-head">
    <div class="col-md-2 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-md-2 col-xs-6">
        <div class="form-group">
            <!-- Document Type -->
            @Html.LabelFor(model => model.DocumentType, Loc.DocumentType, new { @class = "control-label" })
            <select autocomplete="off" class="form-control selectpicker reload-on-change" id="DocType" multiple="multiple" title="@Loc.Select">
                @foreach (var pm in Model.DocTypes)
                {
                    <option value="@pm.Key">@pm.Text</option>
                }
            </select>
        </div>
    </div>
    <div class="col-md-2 col-xs-6">
        <div class="form-group">
            @Html.Label(Loc.Subject, new { @class = "control-label" })
            <select id="SubjectId"
                    name="SubjectId"
                    data-placeholder="@Loc.Subject"
                    class="form-control select2withAPI"
                    data-url="@Url.Action("SearchSubjects", "TravelOrdersDistances")"
                    data-column-names="@Loc.Company,@Loc.Name,@Loc.Address,@Loc.Post"
                    data-bootstrap-columns="col-md-4,col-md-4,col-md-3,col-md-1"
                    data-selector-separator=" | "
                    data-allow-clear="true"
                    data-search-width="800"
                    data-search-left="-100"></select>
        </div>
    </div>
    <div class="col-md-2 col-xs-6">
        <div class="form-group">
            <label>@Loc.PaymentMethod</label>
            <input name="Input_PaymentMethod" type="hidden">
            <div class="dropdown bootstrap-select show-tick form-control">
                <select autocomplete="off" class="form-control selectpicker" id="PaymentMethod" multiple="multiple" title="@Loc.Select">
                    @*<option value="0">@Loc.All</option>*@
                    @foreach (var pm in Model.PaymentMethods)
                    {
                        <option value="@pm.Key">@pm.Text</option>
                    }
                </select>
            </div>
        </div>
    </div>
    <div class="col-md-1 col-xs-6">
        <div class="form-group">
            <label>@Loc.Currency</label>
            <select id="Currency"
                    name="Currency"
                    class="form-control select2withAPI"
                    data-allow-clear="true"
                    data-search-width="100"
                    data-url=@Url.Action("GetDropDownValues", "GlobalHelper", new { apiPath = "/v1/travel-orders/expenses/currencies-lookupitems" })></select>
        </div>
    </div>
    @*<div class="col-md-1 col-xs-6">
        <div class="form-group">
            <label>@Loc.DisplayType</label>
            <select id="PeriodFilter" class="form-control custom-select reload-on-change">
                <option value="@ItemsDisplayFilterType.LastTen">@Loc.LastTen</option>
                <option value="@ItemsDisplayFilterType.LastMonth">@Loc.LastMonth</option>
                <option value="@ItemsDisplayFilterType.LastQuarter">@Loc.LastQuarter</option>
                <option value="@ItemsDisplayFilterType.CustomDate" selected="selected">@Loc.CustomDate</option>
            </select>
        </div>
    </div>*@
    <div class="col-md-1 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 reload-on-change" id="DateFrom" name="DateFrom" type="text" value="@DateTime.Now.Date.AddDays(-1).ToString(Loc.DateFormat)">
            </div>
        </div>
    </div>
    <div class="col-md-1 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 reload-on-change" id="DateTo" name="DateTo" type="text" value="@DateTime.Now.Date.ToString(Loc.DateFormat)">
            </div>
        </div>
    </div>
</div>

<div class="project-list">
    <div class="document-list">
        <table id="cashtransactions" data-grid-id="cash-transactions" data-url="@Url.Action("List", "CashTransactions", new { type = Model.Type })" class="list-table">
            <thead>
                <tr>
                    <th data-function="openPdfPreview('@Url.Action("PAASPrintByAcKeyAndType", "Move")?fiscalize=false&preview={2}&acKey={0}&type={1}')"
                        data-reportTree-I="ReportTreeDisbursement"
                        data-reportTree-P="ReportTreeReceipt">
                    </th>
                    <th data-url="@Url.Action("Index","CashTransactions")?type=@Model.Type&acKey=">@Loc.AcKey</th>
                    <th>@Loc.Subject</th>
                    <th>@Loc.Date</th>
                    <th class="text-right">@Loc.Receipt</th>
                    <th class="text-right">@Loc.Expenditure</th>
                    <th>@Loc.Currency</th>
                    <th>@Loc.DocumentNumber</th>
                    <th>@Loc.PaymentMethod</th>
                    <th>@Loc.Status</th>
                </tr>
            </thead>
        </table>
    </div>

    <!-- Footer -->
    <div class="row document-footer document-footer-sm">
        <div class="col-xs-5">
            <div class="form-group">
                <span>@Loc.NumberOfRows:</span>
                <span id="TotalItems" class="font-bold"></span>
            </div>
        </div>
        <div class="col-xs-2">
            <div class="form-group text-center">
                <span>@Loc.ReceiptSum: </span><span id="ReceiptSum" class="font-bold"></span>
            </div>
        </div>
        <div class="col-xs-2">
            <div class="form-group text-center">
                <span>@Loc.DisbursementSum: </span><span id="DisbursementSum" class="font-bold"></span>
            </div>
        </div>
        <div class="col-xs-3 document-head-highlight-input">
            <div class="form-group text-center">
                <span>@Loc.ReceiptDisbursementSum: </span><span id="TotalSum" class="font-bold"></span>
            </div>
        </div>
    </div>
</div>

@Html.Partial("~/Views/Shared/Components/_sidePanel.cshtml", new PantheonRA.BackOffice.Models.SidePanelViewModel { Id = "pdfPanel" })
<input type="hidden" id="customDateEnum" value="@PantheonRA.BackOffice.Enums.ItemsDisplayFilterType.CustomDate" />

<script>
    function openPdfPreview(url) {
        loadPdfPanelContentPAAS($("#pdfPanel"), url, true);
    }
</script>

<!-- Remove on refactor -->
<style>
    .side-panel {
        right: -18px !important;
        top: 47px;
    }
</style>