LocalGovIMS_localgov-ims/src/Admin/Views/EReturn/Details.cshtml
@using BusinessLogic.Extensions
@using BusinessLogic.Enums
@model Admin.Models.EReturn.EditViewModel
@{
    ViewBag.Title = "eReturn Details";
}

@section Header { @Model.EReturn.EReturn.EReturnNo }

@section Subheader { eReturn details }

@section Actions {
    <button type="button" name="action" id="reprint" class="btn btn-primary print">Print</button>
}

@Html.Partial("_Header", Model)

<nav class="mt-2 ereturn-tab-wrapper">
    <div class="nav nav-tabs nav-fill" id="nav-tab" role="tablist">
        <button class="nav-link active fw-bold" id="nav-ereturn-details-tab" data-bs-toggle="tab" data-bs-target="#nav-ereturn-details" type="button" role="tab" aria-controls="nav-ereturn-details" aria-selected="true">
            eReturn details <span class="badge text-bg-success fs-3 py-2 px-3 ms-1 transaction-total">£@Model.EReturn.Amount.ToTwoDecimalPlaces()</span>
        </button>
        <button class="nav-link fw-bold" id="nav-analysis-tab" data-bs-toggle="tab" data-bs-target="#nav-analysis" type="button" role="tab" aria-controls="nav-analysis" aria-selected="false">
            @((EReturnType)Model.EReturn.EReturn.TypeId == EReturnType.Cash ? "Cash analysis" : "Cheque analysis") <span class="badge text-bg-success fs-3 py-2 px-3 ms-1 analysis-total">£@((EReturnType)Model.EReturn.EReturn.TypeId == EReturnType.Cash ? Model.Cash.Total.ToTwoDecimalPlaces() : Model.Cheques == null ? 0 : Model.Cheques.Sum(x => x.Amount).ToTwoDecimalPlaces())</span>
        </button>
    </div>
</nav>

@Html.HiddenFor(m => m.EReturn.EReturn.Id)
@Html.HiddenFor(m => m.EReturn.EReturn.TypeId)

<div class="tab-content border border-top-0 p-2" id="nav-tabContent">
    <div class="tab-pane show active" id="nav-ereturn-details" role="tabpanel" aria-labelledby="nav-ereturn-details-tab" tabindex="0">
        <div class="table-responsive-sm">
            <table class="table table-striped table-bordered table-hover mt-2">
                <thead>
                    <tr>
                        <th scope="col" id="Reference">Reference</th>
                        <th scope="col" id="Description">Description</th>
                        <th scope="col" id="Amount">Amount</th>
                        <th scope="col" id="VatCode" style="min-width:200px">VAT code</th>
                    </tr>
                </thead>
                <tbody id="template-rows">
                    @if (Model.Transactions.Any())
                    {
                        for (int i = 0; i < Model.Transactions.Count; i++)
                        {
                            @Html.HiddenFor(m => m.Transactions[i].Id)
                            @Html.HiddenFor(m => m.Transactions[i].TemplateRowId)
                            <tr>
                                <td>
                                    @Model.Transactions[i].Reference
                                </td>
                                <td>
                                    @Model.Transactions[i].Description
                                    @Html.HiddenFor(m => m.Transactions[i].Description)
                                </td>
                                <td>
                                    @Html.TextBoxFor(m => m.Transactions[i].Amount, "{0:F2}", new { @class = "transaction-value form-control", @maxlength = "18", aria_labelledby = "Amount" })
                                </td>
                                <td>
                                    @Model.Transactions[i].VatCode
                                </td>
                            </tr>
                        }
                    }
                </tbody>
            </table>
        </div>
    </div>

    @Html.HiddenFor(m => m.Cash.Id)
    <div class="tab-pane" id="nav-analysis" role="tabpanel" aria-labelledby="nav-analysis-tab" tabindex="0">
        <div class="table-responsive-sm">
            <table class="table table-striped table-bordered table-hover mt-2">

                @if ((EReturnType)Model.EReturn.EReturn.TypeId == EReturnType.Cash)
                {
                    @Html.HiddenFor(m => m.Cash.Id)
                    <thead>
                        <tr>
                            <th scope="col">Denomination</th>
                            <th scope="col" id="CashValue">Value</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td id="BagNumber">Bag number</td>
                            <td>@Html.DisplayFor(m => m.Cash.BagNumber)</td>
                        </tr>
                        <tr>
                            <td id="50Pounds">£50</td>
                            <td>@Html.TextBoxFor(m => m.Cash.Pounds50, "{0:F2}", new { @class = "analysis-value monetary-amount form-control", @data_step = "50", @maxlength = "18", aria_labelledby = "50Pounds CashValue" })</td>
                        </tr>
                        <tr>
                            <td id="20Pounds">£20</td>
                            <td>@Html.TextBoxFor(m => m.Cash.Pounds20, "{0:F2}", new { @class = "analysis-value monetary-amount form-control", @data_step = "20", @maxlength = "18", aria_labelledby = "20Pounds CashValue" })</td>
                        </tr>
                        <tr>
                            <td id="10Pounds">£10</td>
                            <td>@Html.TextBoxFor(m => m.Cash.Pounds10, "{0:F2}", new { @class = "analysis-value monetary-amount form-control", @data_step = "10", @maxlength = "18", aria_labelledby = "10Pounds CashValue" })</td>
                        </tr>
                        <tr>
                            <td id="5Pounds">£5</td>
                            <td>@Html.TextBoxFor(m => m.Cash.Pounds5, "{0:F2}", new { @class = "analysis-value monetary-amount form-control", @data_step = "5", @maxlength = "18", aria_labelledby = "5Pounds CashValue" })</td>
                        </tr>
                        <tr>
                            <td id="2Pounds">£2</td>
                            <td>@Html.TextBoxFor(m => m.Cash.Pounds2, "{0:F2}", new { @class = "analysis-value monetary-amount form-control", @data_step = "2", @maxlength = "18", aria_labelledby = "2Pounds CashValue" })</td>
                        </tr>
                        <tr>
                            <td id="1Pound">£1</td>
                            <td>@Html.TextBoxFor(m => m.Cash.Pounds1, "{0:F2}", new { @class = "analysis-value monetary-amount form-control", @data_step = "1", @maxlength = "18", aria_labelledby = "1Pound CashValue" })</td>
                        </tr>
                        <tr>
                            <td id="50Pence">50p</td>
                            <td>@Html.TextBoxFor(m => m.Cash.Pence50, "{0:F2}", new { @class = "analysis-value monetary-amount form-control", @data_step = "0.50", @maxlength = "18", aria_labelledby = "50Pence CashValue" })</td>
                        </tr>
                        <tr>
                            <td id="20Pence">20p</td>
                            <td>@Html.TextBoxFor(m => m.Cash.Pence20, "{0:F2}", new { @class = "analysis-value monetary-amount form-control", @data_step = "0.20", @maxlength = "18", aria_labelledby = "20Pence CashValue" })</td>
                        </tr>
                        <tr>
                            <td id="10Pence">10p</td>
                            <td>@Html.TextBoxFor(m => m.Cash.Pence10, "{0:F2}", new { @class = "analysis-value monetary-amount form-control", @data_step = "0.10", @maxlength = "18", aria_labelledby = "10Pence CashValue" })</td>
                        </tr>
                        <tr>
                            <td id="5Pence">5p</td>
                            <td>@Html.TextBoxFor(m => m.Cash.Pence5, "{0:F2}", new { @class = "analysis-value monetary-amount form-control", @data_step = "0.05", @maxlength = "18", aria_labelledby = "5Pence CashValue" })</td>
                        </tr>
                        <tr>
                            <td id="2Pence">2p</td>
                            <td>@Html.TextBoxFor(m => m.Cash.Pence2, "{0:F2}", new { @class = "analysis-value monetary-amount form-control", @data_step = "0.02", @maxlength = "18", aria_labelledby = "2Pence CashValue" })</td>
                        </tr>
                        <tr>
                            <td id="1Pence">1p</td>
                            <td>@Html.TextBoxFor(m => m.Cash.Pence1, "{0:F2}", new { @class = "analysis-value monetary-amount form-control", @data_step = "0.01", @maxlength = "18", aria_labelledby = "1Pence CashValue" })</td>
                        </tr>
                    </tbody>
                }

                @if ((EReturnType)Model.EReturn.EReturn.TypeId == EReturnType.Cheque)
                {
                    <thead>
                        <tr>
                            <th scope="col" id="ChequeName">Name on cheque</th>
                            <th scope="col" id="ChequeValue">Value</th>
                            <th scope="col"><span class="visually-hidden">Actions</span></th>
                        </tr>
                    </thead>
                    <tbody id="cheque-rows">
                        @for (int i = 0; i < Model.Cheques.Count; i++)
                        {
                            <tr>
                                <td>@Html.TextBoxFor(m => m.Cheques[i].Name, new { @maxlength = "100", @class = "form-control", aria_labelledby = "ChequeName" })</td>
                                <td>@Html.TextBoxFor(m => m.Cheques[i].Amount, "{0:F2}", new { @class = "analysis-value monetary-amount form-control", @maxlength = "18", aria_labelledby = "ChequeValue" })</td>
                                <td class="text-end">
                                    <a class="btn btn-danger remove-cheque" data-remove="@i">Remove</a>
                                </td>
                            </tr>
                        }
                    </tbody>
                    <tfoot>
                        <tr>
                            <td colspan="3">
                                <a id="add-row" class="btn btn-primary add-cheque">Add row</a>
                            </td>
                        </tr>
                    </tfoot>
                }

            </table>
        </div>
    </div>

</div>

<div class="mt-3">
    @Html.ActionLink("Back", "Back", "EReturn", null, new { @class = "btn btn-secondary" })
</div>

@section Scripts {
    @Scripts.Render("~/bundles/app/ereturn")
}