<!DOCTYPE html>
<html lang="en"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Order</title>
    <script
            src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css"
          integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB"
          crossorigin="anonymous">
    <link href="../static/App.css" rel="stylesheet" media="screen" th:href="@{/App.css}"/>
    <script
            src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div th:replace="/base/baseapp :: header" class="App-header">...</div>
<div th:replace="/base/baseapp :: nav" class="App-header">...</div>
<div class="container">
    <div class="btn-group mb-5">
        <a class="btn button-go4me" th:href="@{/searchorders}">Back!</a>
        <form class="btn-group" th:if="${isMyOrder}" th:action="@{'/order/' + ${Order.getID()}}" method="POST">
            <button type="submit" class="btn button-go4me">Delete Order!</button>
        </form>
        <form class="btn-group" th:if="${!isMyOrder && !isAssigned}"
              th:action="@{'/searchorders/?id=' + ${Order.getID()}}" method="POST">
            <button type="submit" class="btn button-go4me">Assign Order!</button>
        </form>
        <form class="btn-group" th:if="${isAssigned && (!isVerifiedByBuyer || !isVerifiedBySeller)}"
              th:action="@{'/index/?id=' + ${Order.getID()}}"
              method="post">
            <button type="submit" class="btn button-go4me">Verify</button>
        </form>
    </div>
    <div class="row bg-dark text-white" style="border-radius: 21px 21px 21px 21px">
        <div class="col-md-12 pt-3 px-3 pt-md-5 pb-md-5 px-md-5">
            <h3>Order Info</h3>
            <div class="row">
                <div class="col-md-4 row">
                    <div class="col-auto">ID:</div>
                    <div th:text="${Order.getID()}" class="card-text col-auto"></div>
                </div>
                <div class="col-md-4 row">
                    <div class="col-auto">Published by:</div>
                    <a th:text="${Order.getPublishedBy().getUserName()}" class="link"
                       th:href="@{'/profile/' + ${Order.getPublishedBy().getUserName()}}"></a>
                </div>
                <div class="col-md-4 row mb-2">
                    <div class="col-auto">Assigned to:</div>
                    <div th:if="${Order.getBuyer() != null}">
                        <a th:text="${Order.getBuyer().getUserName()}"
                           class="link" th:href="'/profile/' + ${Order.getBuyer().getUserName()}"></a>
                    </div>
                    <div th:if="${Order.getBuyer() == null}">
                        Nobody
                    </div>
                </div>
                <div class="col-md-4 row">
                    <div class="col-auto">Hour:</div>
                    <div th:text="${Order.getHour()}" class="card-text col-auto"></div>
                </div>
                <div class="col-md-4 row">
                    <div class="col-auto">Day:</div>
                    <div th:text="${Order.getDay()}" class="card-text col-auto"></div>
                </div>
                <div class="col-md-4 row mb-2">
                    <div class="col-auto">Month:</div>
                    <div th:text="${Order.getMonth()}" class="card-text col-auto"></div>
                </div>
                <div class="col-md-4 row">
                    <div class="col-auto">Cost:</div>
                    <div th:text="${Order.getMaxCost()}" class="card-text col-auto"></div>
                </div>
                <div class="col-md-4 row mb-2">
                    <div class="col-auto">Verified by Seller:</div>
                    <div th:if="${Order.getSeller() != null && Order.isVerifiedBySeller() == 1}">
                        Verified
                    </div>
                    <div th:if="${Order.getSeller() == null || !isVerifiedBySeller}">
                        <div th:if="${isAssigned}">Not Verified</div>
                        <div th:if="${!isAssigned && !isVerifiedBySeller}">Not assigned</div>
                    </div>
                </div>
                <div class="col-md-4 row mb-2">
                    <div class="col-auto">Verified by Buyer:</div>
                    <div th:if="${Order.getBuyer() != null && Order.isVerifiedByBuyer() == 1}">
                        Verified
                    </div>
                    <div th:if="${Order.getBuyer() == null || !isVerifiedByBuyer}">
                        <div th:if="${isAssigned}">Not Verified</div>
                        <div th:if="${!isAssigned && !isVerifiedByBuyer}">Not assigned</div>
                    </div>
                </div>
                <div class="col-md-4 row mb-2">
                    <div class="col-auto">Description:</div>
                    <div th:text="${Order.getDescription()}" class="card-text col-auto"></div>
                </div>
            </div>
        </div>
        <div class="card-body col-auto">
        </div>
    </div>
</div>
</body>
</html>