<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.w3.org/1999/xhtml"
      xmlns:v-bind="http://www.w3.org/1999/xhtml">
<head th:replace="_fragments :: head('Packaging Receive Inventory')"></head>
<body>
<div class="container-fluid">
    <header class="row page-header" th:replace="_fragments :: page-header"></header>
    <main class="row page-main">
        <div class="col-sm">
            <div th:replace="_notices :: page-notices"></div>
            <div class="mb-4 d-flex justify-content-between">
                <h3>Receive Packing Items</h3>
            </div>
            <form th:action="'/ctp/packaging/packaging-items'" method="post" id="packagingApp" th:object="${wrapper}">
                <div class="bg-light p-3 mb-3">
                    <div class="form-row">
                        <div class="col-sm-3 form-group">
                            <search-item
                                    :is-segregated="true"
                                    url="/ctp/rest/finished-items/search-packaging"
                                    v-on:finished-item-select="onItemSelect">
                            </search-item>
                        </div>
                        <div class="col-sm-3 form-group">
                            <label>Packaging Account</label>
                            <select class="form-control" name="account-id" th:field="*{accountId}" required>
                                <option value="">PLease select</option>
                                <option th:each="account : ${accounts}"
                                        th:value="${account.id}"
                                        th:text="${account.title}"></option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="bg-light p-3 mb-3">
                    <h6 class="mb-3">Search Finished Items</h6>
                    <finish-item-table
                            v-bind:items="items"
                            v-on:remove-item="removeItem"
                    ></finish-item-table>
                </div>
                <div class="alert alert-danger" v-if="hasDuplicates()" >Duplicate Item Selected</div>
                <button class="btn btn-primary" type="submit" v-bind:disabled="hasDuplicates()">Submit</button>
                <a th:href="@{/packaging/receive-inventory}" class="btn btn-light">Cancel</a>
            </form>
            <script th:inline="javascript">
                window.ctp.accounts = [[${accounts}]];
            </script>
            <script th:src="@{/js/vendor/compressor.min.js}"></script>
            <script th:src="@{/js/packaging/packaging-item-form.js}"></script>
        </div>
    </main>
</div>
<div th:replace="_fragments :: page-footer-scripts"></div>
</body>
</html>