@model economy.Models.View<economy.Models.Price.Domestic.Item.Detail.Request, economy.Models.Price.Domestic.Item.Detail.Response>

@{
    ViewData["Title"] = "품목 가격 정보";
}

<div class="container">
    <h3>품목 가격 정보</h3>

    <p class="mb-0">
        @Model.Response.Body?.In | <small>@Model.Response.Body?.Ic</small>
    </p>

      <div class="row mt-3">
        <div class="col align-self-center">
            @((Model?.Response?.Body?.TotalCount ?? 0).ToString("N0")) 개
        </div>
        <div class="col-auto">
            <div class="row g-2">
                <div class="col">
                    <input type="date" name="sDate" id="sDate" class="form-control" value="@Model.Request.StartDate.ToString("yyyy-MM-dd")" form="fSearch" />
                </div>
                <div class="col">
                    <input type="date" name="eDate" id="eDate" class="form-control" value="@Model.Request.EndDate.ToString("yyyy-MM-dd")" form="fSearch" />
                </div>
                <div class="col">
                    <select name="perPage" id="perPage" class="form-select" asp-for="SelectedListPerPage" asp-items="Model.ListPerPage" form="fSearch"></select>
                </div>
            </div>
        </div>
    </div>

    <div class="table-responsive">
        <table id="priceItemInfo" class="table table-bordered table-hover">
            <caption class="caption-top">
                
            </caption>
            @if (Model.Response.Body != null)
            {
                <colgroup>
                    <col width="7%"/>
                    <col width="10%"/>
                    <col width="*"/>
                    <col width="8%"/>
                    <col width="8%"/>
                    <col width="8%"/>
                    <col width="10%"/>
                </colgroup>
            }
            <thead>
                <tr>
                    <th>번호</th>
                    <th>상품 ID</th>
                    <th>상품 명</th>
                    <th>판매가격</th>
                    <th>할인가격</th>
                    <th>혜택가격</th>
                    <th>가격일자</th>
                </tr>
            </thead>
            <tbody>
                @if (Model.Response.Body != null)
                {
                    @foreach (var row in Model.Response.Body.Items.ItemList)
                    {
                        <tr>
                            <td>@row.Num</td>
                            <td>@row.Pi</td>
                            <td class="text-start">@row.Pn</td>
                            <td>@row.Sp.ToString("N0")</td>
                            <td>@row.Dp.ToString("N0")</td>
                            <td>@row.Bp</td>
                            <td>@row.Sd</td>
                        </tr>
                    }
                }
                else
                {
                    <tr>
                        <td colspan="7">
                            No data.
                        </td>
                    </tr>   
                }
            </tbody>
        </table>
    </div>

    <form id="fSearch" method="get" accept-charset="UTF-8" rel="search" autocomplete="off" asp-controller="Price" asp-action="Detail">
        <input type="hidden" name="page" value="@Model.Request.PageNo"/>
    </form>

    @await Html.PartialAsync("~/Views/Component/Pagination.cshtml", Model.Pagination)

</div>

@section Scripts {
    <script src="~/js/price.js" asp-append-version="true"></script>
}
@section Styles {
    <link href="~/css/style.css" rel="stylesheet" asp-append-version="true"/>
}