<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.w3.org/1999/xhtml"
      xmlns:uind="http://www.w3.org/1999/xhtml" xmlns:ctp="http://www.w3.org/1999/xhtml">
    <head th:replace="_fragments :: head('Qc Finished Item')"></head>
    <body>
        <div class="container-fluid">
            <header class="row page-header" th:replace="_fragments :: page-header"></header>
            <main class="row page-main">
                <!-- sidebar starts -->
                <aside class="col-sm-2" th:replace="/finishing/_finished-item-sidebar :: sidebar"></aside>
                <!-- sidebar ends -->
                <!--header starts-->
                <div class="col-sm">
                    <div th:replace="_notices :: page-notices"></div>
                    <div class="mb-4 d-flex justify-content-between">
                        <h3>QC Items</h3>
                        <a th:href="@{/quality-control/qc-finished-item}" class="btn btn-primary">Add Items For QC</a>
                    </div>
                    <div th:replace="_fragments :: table-loading-skeleton"></div>
                    <form th:action="@{/cutting/generate-barcodes}" method="post">
                        <input hidden="hidden" name="artifactType" value="Bundle">
                        <table class="table table-striped" data-table data-order="[[ 0, &quot;desc&quot; ]]">
                            <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>Item ID</th>
                                    <th>Sku</th>
                                    <th>Job Card ID</th>
                                    <th>Is QA</th>
                                    <th>Created At</th>
                                    <th>Created By</th>
                                    <th>Segregated</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr th:each="item : ${items}">
                                    <td th:text="${item.id}"></td>
                                    <td th:text="${item.itemId}"></td>
                                    <td th:text="${item.sku}"></td>
                                    <td th:text="${item.jobCardId}"></td>
                                    <td>
                                        <span th:if="${not item.isQa}" class="badge badge-danger">NOT PERFORMED</span>
                                        <div th:if="${item.isQa}">
                                            <span class="badge badge-APPROVED">PERFORMED</span>
                                        </div>
                                        <div th:if="${item.qaStatus != null }">
                                            <span th:text="${item.qaStatus}"></span>
                                        </div>
                                    </td>
                                    <td th:text="${item.createdBy}"></td>
                                    <td ctp:formatdatetime="${item.createdAt}"></td>
                                    <td>
                                        <span th:if="${not item.isSegregated && item.qaStatus != 'ALTER'}" class="badge badge-danger">PENDING</span>
                                        <span th:if="${not item.isSegregated && item.qaStatus == ('ALTER')}" class="badge badge-warning" >REVERTED</span>
                                        <div th:if="${item.isSegregated && item.qaStatus != ('ALTER')}">
                                            <span class="badge badge-APPROVED">DONE</span>
                                        </div>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </form>
                </div>
            </main>
        </div>
        <div th:replace="_fragments :: page-footer-scripts"></div>
    </body>
</html>