<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:ctp="http://www.w3.org/1999/xhtml">
    <head th:replace="_fragments :: head('View Master Bundle')"></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">
                    <table class="table table-bordered w-75" th:object="${masterBundle}">
                        <thead class="thead-dark">
                            <tr>
                                <th colspan="2" class="text-center">
                                    <span th:text="*{ 'MASTER-BUNDLE-' + id}"></span>
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td width="200"><i>Item ID</i></td>
                                <td th:text="*{itemId}"></td>
                            </tr>
                            <tr>
                                <td><i>Sku</i></td>
                                <td th:text="*{sku}"></td>
                            </tr>
                            <tr>
                                <td><i>Barcode</i></td>
                                <td th:text="*{barcode}"></td>
                            </tr>
                            <tr>
                                <td><i>Created By</i></td>
                                <td th:text="*{createdBy}"></td>
                            </tr>
                            <tr>
                                <td><i>Created At</i></td>
                                <td ctp:formatdatetime="*{createdAt}"></td>
                            </tr>
                            <tr>
                                <td>Stitching Status</td>
                                <td>
                                    <span th:if="*{ not isReceived}" class="badge badge-danger">NOT RECEIVED</span>
                                    <div th:if="*{isReceived}">
                                        <span class="badge badge-APPROVED">RECEIVED</span>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td>Production</td>
                                <td><span th:text="*{totalProduction}"></span> out of <span th:text="*{expectedProduction}"></span></td>
                            </tr>
                            <tr th:if="${masterBundle.bundles != null and #lists.size(masterBundle.bundles) > 0}">
                                <td><i>Bundles</i></td>
                                <td class="p-0">
                                    <table class="w-100">
                                        <thead>
                                            <tr>
                                                <th>ID</th>
                                                <th>Item ID</th>
                                                <th>Sku</th>
                                                <th>Job Card ID</th>
                                                <th>Wrap Quantity</th>
                                                <th>Type</th>
                                                <th>Generated By</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <tr th:each="bundle : *{bundles}" th:object="${bundle}">
                                                <td th:text="*{id}"></td>
                                                <td th:text="*{itemId}"></td>
                                                <td th:text="*{sku}"></td>
                                                <td th:text="*{jobCardId}"></td>
                                                <td th:text="*{wrapQuantity}"></td>
                                                <td th:text="*{type}"></td>
                                                <td><span th:text="*{createdBy}"></span> @ <span ctp:formatdatetime="*{createdAt}"></span></td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </td>
                            </tr>
                            <tr th:if="${masterBundle.items != null and #lists.size(masterBundle.items) > 0}">
                                <td><i>Finished Items</i></td>
                                <td class="p-0">
                                    <table class="w-100">
                                        <thead>
                                            <tr>
                                                <th>ID</th>
                                                <th>Item ID</th>
                                                <th>Sku</th>
                                                <th>QA Status</th>
                                                <th>Generated By</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <tr th:each="item : ${masterBundle.items}" th:object="${item}">
                                                <td th:text="*{id}"></td>
                                                <td th:text="*{itemId}"></td>
                                                <td th:text="*{sku}"></td>
                                                <td>
                                                    <span th:if="*{ not isQa}" class="badge badge-danger">NOT APPROVED</span>
                                                    <div th:if="*{isQa}">
                                                        <span class="badge badge-APPROVED">APPROVED</span>
                                                    </div>
                                                </td>
                                                <td><span th:text="*{createdBy}"></span> @ <span ctp:formatdatetime="*{createdAt}"></span></td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </main>
        </div>
    </body>
</html>