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

@Html.HiddenFor(m => m.Page, new { @id = "pageType" })
@Html.Hidden("LnkTableView", Url.Action("Index", "CashTransactions", new { page = PageType.TableView, type = Model.Type }))
@Html.Hidden("LnkCreateView", Url.Action("Index", "CashTransactions", new { type = Model.Type }))
@Html.Hidden("LnkReceipts", Url.Action("Index", "CashTransactions", new { type = CashTransactionType.Receipt }))
@Html.Hidden("LnkDisbursements", Url.Action("Index", "CashTransactions", new { type = CashTransactionType.Disbursement }))
@Html.Hidden("LnkCashReports", Url.Action("Index", "CashTransactions", new { type = CashTransactionType.CashReport, page = PageType.CashReport }))
@Html.Partial("~/Views/Shared/Components/_PreviewPrintMenuButton.cshtml", new PantheonRA.BackOffice.Models.PreviewReportTreeViewModel { ReportTree = Model.ReportTreeReceipt, Id = "ReportTreeReceipt" })
@Html.Partial("~/Views/Shared/Components/_PreviewPrintMenuButton.cshtml", new PantheonRA.BackOffice.Models.PreviewReportTreeViewModel { ReportTree = Model.ReportTreeDisbursement, Id = "ReportTreeDisbursement" })

<input type="hidden" id="lblConfirmed" value="@Loc.Confirmed" />
<input type="hidden" id="lblNotConfirmed" value="@Loc.NotConfirmed" />

<div class="wrapper wrapper-content">
    <div class="tabs-container">
        <!-- Main Tabs -->
        <ul class="nav nav-tabs horizontal-menu custom-scrollable-tabs">
            <li class="@(Model.Page == PageType.CreateEdit && Model.Type == CashTransactionType.Receipt ? "active" : string.Empty)">
                <a href="#" onclick="changeView('#LnkReceipts')">@Loc.Receipt</a>
            </li>
            <li class="@(Model.Page == PageType.CreateEdit && Model.Type == CashTransactionType.Disbursement ? "active" : string.Empty)">
                <a href="#" onclick="changeView('#LnkDisbursements')">@Loc.Expenditure</a>
            </li>
            <li class="@(Model.Page == PageType.CashReport && Model.Type == CashTransactionType.CashReport ? "active" : string.Empty)">
                <a href="#" onclick="changeView('#LnkCashReports')">@Loc.CashAccounting</a>
            </li>
            <li class="@(Model.Page == PageType.TableView ? "active" : string.Empty)">
                <a href="#" onclick="changeView('#LnkTableView')">@Loc.ListOfReceiptsAndExpenses</a>
            </li>
        </ul>

        <div class="tab-content">
            @if (Model.Page == PageType.CreateEdit && string.IsNullOrWhiteSpace(Model.AcKey))
            {
                { Html.RenderAction("Create", "CashTransactions", new { type = Model.Type, selectedDocType = Model.DocType }); }
            }
            @if (Model.Page == PageType.CreateEdit && !string.IsNullOrWhiteSpace(Model.AcKey))
            {
                { Html.RenderAction("Edit", "CashTransactions", new { type = Model.Type, acKey = Model.AcKey }); }
            }
            @if (Model.Page == PageType.TableView)
            {
                { Html.RenderAction("TableView", "CashTransactions"); }
            }
            @if (Model.Page == PageType.CashReport)
            {
                { Html.RenderAction("CashReport", "CashTransactions"); }
            }
        </div>
    </div>
</div>

@Scripts.Render("~/bundles/cashTransactions")
@Scripts.Render("~/bundles/moment")


<script language="JavaScript" type="text/javascript" src="~/Scripts/jquery-1.10.2.js"></script>
<script src="~/Scripts/custom/global-helpers.js"></script>
<script src="~/Scripts/custom/initializers.js"></script>

<script>
    $(document).ready(function () {

        let pageType = $("#pageType").val();

        if (pageType == "TV") {
            initializeCashTransactions();
        }
        else if (pageType == "CRE") {
            initializeCashReports();
        }
    });
</script>

@* TODO: remove after refactor *@
@section pageScripts{
    @Scripts.Render("~/bundles/validation")
    <script src="~/Scripts/global-script.js"></script>
}