<!DOCTYPE html>
<html lang="ru" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{default}">

<head>
    <title>Панель администратора (заказы)</title>
</head>

<body th:with="bodyClass='bg-white', mainClass='my-0'">
    <main layout:fragment="content">
        <th:block th:switch="${items.size()}">
            <h2 class="mt-4 text-center" th:case="0">Данные отсутствуют</h2>
            <th:block th:case="*">
                <div class="row gy-3">
                    <div class="col-12 mt-4 px-0">
                        <div class="block d-flex justify-content-center fs-2 fw-bold mb-3 mb-sm-4" id="admin-title">
                            Заказы
                        </div>
                    </div>
                    <div class="col-12 px-0">
                        <div class="block table-responsive">
                            <table class="table table-hover table-bordered align-middle">
                                <caption></caption>
                                <thead>
                                    <tr>
                                        <th scope="col">ID</th>
                                        <th scope="col">Дата заказа</th>
                                        <th scope="col">Стоимость</th>
                                        <th scope="col">Количество книг</th>
                                        <th scope="col"></th>
                                        <th scope="col"></th>
                                    </tr>
                                </thead>
                                <tbody class="table-group-divider">
                                    <tr th:each="order : ${items}">
                                        <th scope="row" th:text="${order.id}"></th>
                                        <td th:text="${order.date}"></td>
                                        <td th:text="${#numbers.formatDecimal(order.sum, 1, 2)}"></td>
                                        <td th:text="${order.count}"></td>
                                        <td>
                                            <form th:action="@{/admin/order/check/{id}(id=${order.id})}" method="get">
                                                <input type="hidden" th:name="page" th:value="${page}">
                                                <button type="submit" class="btn btn-primary w-100">Подробнее</button>
                                            </form>
                                        </td>
                                        <td>
                                            <form th:action="@{/admin/order/delete/{id}(id=${order.id})}" method="post">
                                                <input type="hidden" th:name="page" th:value="${page}">
                                                <button type="submit" class="btn btn-primary w-100"
                                                    onclick="return confirm('Вы уверены?')">Удалить</button>
                                            </form>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <th:block th:replace="~{ pagination :: pagination (
                                                                        url=${'admin/order'},
                                                                        totalPages=${totalPages},
                                                                        currentPage=${currentPage},
                                                                        filter='',
                                                                        searchInfo='') }" />
                </div>
            </th:block>
    </main>
</body>

</html>