<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<div th:replace="~{common :: head}"></div>

<body>
<div th:replace="~{common :: page-header}"></div>

<div class="indent">
    <form method="get" action="/operations">
        <table class="table">
            <thead class="theme-dark">
            <tr>
                <th colspan="6">Фильтры</th>
            </tr>
            </thead>
            <tbody>
            <tr>
                <td>Тип</td>
                <td>
                    <select id="operationTypeFilter" name="operationType">
                        <option value="">Любой</option>
                        <option th:value="'SUPPLY'" th:text="SUPPLY" th:selected="${operationTypeFilter == 'SUPPLY'}"></option>
                        <option th:value="'ISSUE'" th:text="ISSUE" th:selected="${operationTypeFilter == 'ISSUE'}"></option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>Статус</td>
                <td>
                    <select id="operationStatusFilter" name="operationStatus">
                        <option value="">Любой</option>
                        <option th:value="'CHECKOUT'" th:text="CHECKOUT" th:selected="${operationStatusFilter == 'CHECKOUT'}"></option>
                        <option th:value="'APPROVAL'" th:text="APPROVAL" th:selected="${operationStatusFilter == 'APPROVAL'}"></option>
                        <option th:value="'READY'" th:text="READY" th:selected="${operationStatusFilter == 'READY'}"></option>
                        <option th:value="'EXECUTED'" th:text="EXECUTED" th:selected="${operationStatusFilter == 'EXECUTED'}"></option>
                        <option th:value="'CANCELLED'" th:text="CANCELLED" th:selected="${operationStatusFilter == 'CANCELLED'}"></option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>Включает товар с названием</td>
                <td>
                    <input type="text" id="operationProductNameFilter" name="operationProductName" th:value="${operationProductNameFilter}">
                </td>
            </tr>
            <tr>
                <td>Партнер (название)</td>
                <td>
                    <input type="text" id="operationPartnerNameFilter" name="operationPartnerName" th:value="${operationPartnerNameFilter}">
                </td>
            </tr>
            <tr>
                <td colspan="6"><input id="saveBtn" type="submit" value="Применить" class="btn btn-primary"></td>
            </tr>
            </tbody>
        </table>
    </form>

    <table class="table table-bordered table-warning">
        <thead class="thead-dark">
        <tr>
            <th scope="col">№</th>
            <th scope="col">Тип</th>
            <th scope="col">Партнер</th>
            <th scope="col">Статус</th>
        </tr>
        </thead>
        <tbody>
        <tr th:if="${operations.isEmpty()}">
            <td colspan="6">Данному фильтру не удовлетворяет ни одной операции.</td>
        </tr>
        <tr th:each="operation : ${operations}">
            <td>
                <a th:href="'/operation?id=' + ${operation.getId()}">
                    <span th:text="${operation.getId()}"></span>
                </a>
            </td>
            <td>
                <span th:text="${operation.getType()}"></span>
            </td>
            <td>
                <span th:text="${operation.getPartner().getName()}"></span>
            </td>
            <td>
                <span th:text="${operation.getStatus()}"></span>
            </td>
        </tr>
        </tbody>
    </table>
</div>

<div th:replace="~{common :: site-footer}"></div>
<div th:replace="~{common :: site-script}"></div>
</body>
</html>