@model economy.Models.View<economy.Models.Flower.Request, economy.Models.Flower.Response>

@{
    ViewData["Title"] = "화훼 시세";
}

<div class="container">
    <h3>화훼 시세</h3>

    <div class="row g-2 mt-3">
        <div class="col-sm col-md-auto">
            <input type="search" name="pName" id="pName" class="form-control" value="@Model.Request.PumName" form="fSearch" placeholder="품목명" />
        </div>
        <div class="col-sm col-md-auto">
            <input type="search" name="gName" id="gName" class="form-control" value="@Model.Request.GoodName" form="fSearch" placeholder="품종명" />
        </div>
        <div class="col col-md-auto text-center text-md-start">
            <button type="submit" class="btn btn-secondary" form="fSearch">검색</button>
        </div>
    </div>

    <div class="row mt-3">
        <div class="col align-self-center">
            @((Model?.Response?.NumberOfRows ?? 0).ToString("N0")) 개
        </div>
        <div class="col-auto">
            <div class="row g-2">
                <div class="col">
                    <input type="date" name="date" id="date" class="form-control" value="@Model.Request.BaseDate.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="flowerPrice" class="table table-bordered table-hover">
            <caption class="caption-top">
                총금액 단위:원 / 총물량 단위:속
            </caption>
            <thead>
                <tr>
                    <th>번호</th>
                    <th>기준일자</th>
                    <th>부류</th>
                    <th>품목명</th>
                    <th>품종명</th>
                    <th>등급명</th>
                    <th>최고가</th>
                    <th>최저가</th>
                    <th>평균가</th>
                    <th>총금액</th>
                    <th>총물량</th>
                </tr>
            </thead>
            <tbody>
                @if (Model.Response.Items != null && Model.Response?.NumberOfRows > 0)
                {
                    @foreach (var row in Model.Response.Items)
                    {
                        <tr>
                            <td>@row.Num</td>
                            <td>@row.SaleDate</td>
                            <td>@row.FlowerGubn</td>
                            <td>@row.PumName</td>
                            <td>@row.GoodName</td>
                            <td>@row.LvNm</td>
                            <td>@row.MaxAmt</td>
                            <td>@row.MinAmt</td>
                            <td>@row.AvgAmt</td>
                            <td>@row.TotAmt</td>
                            <td>@row.TotQty</td>
                        </tr>
                    }
                }
                else
                {
                    <tr>
                        <td colspan="11">
                            No data.
                        </td>
                    </tr>
                }
            </tbody>
        </table>
    </div>

    <form id="fSearch" method="get" accept-charset="UTF-8" rel="search" autocomplete="off" asp-controller="Flower" asp-action="Index">
        <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/flower.js" asp-append-version="true"></script>
}
@section Styles {
    <link href="~/css/style.css" rel="stylesheet" asp-append-version="true" />
}