<!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('Create Stitching Item')"></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>
                    <h3 class="pb-2">Create Stitching Items</h3>
                    <form th:action="@{/stitching/create-stitching-items}"
                          method="POST"
                          id="finishedItemApp"
                          th:object="${bundleWrapper}">

                        <div class="bg-light p-3 mb-3 col-sm-8">
                            <div class="form-row">
                                <div class="col-sm-5 p-0">
                                    <bundle-search-by-barcode
                                            v-bind:id-field-name="'id'"
                                            v-bind:filter="false"
                                            v-bind:items="true"
                                            v-on:job-card-select="onBundleSelects">
                                    </bundle-search-by-barcode>
                                </div>
                            </div>
                        </div>
                        <div class="bg-light p-3 mb-3 col-sm-8">
                            <h6>Items</h6>
                            <div class="form-row col-sm-12">
                                <table class="table mt-2 table-bordered table-hover bg-white">
                                    <tr>
                                        <th></th>
                                        <th>ID</th>
                                        <th>Item ID</th>
                                        <th>Sku</th>
                                        <th>Expected Production</th>
                                        <th>Current Production</th>
                                        <th>Production</th>
                                    </tr>
                                    <tbody>
                                        <tr v-if="(item.wrapQuantity !== item.production)" v-for="(item,index) in items">
                                            <td  >
                                                <div class="form-group form-check mb-0">
                                                    <input class="form-check-input" type="checkbox" v-bind:name="'items[' + index + '].isSelected'" v-model="item.isSelected">

                                                </div>
                                            </td>
                                            <td>
                                                <input hidden="hidden" v-bind:name="'bundles[' + index + '].jobCardId'" v-bind:value="item.jobCardId">
                                                <input hidden="hidden" v-bind:name="'bundles[' + index + '].itemId'" v-bind:value="item.itemId">
                                                <input hidden="hidden" v-bind:name="'bundles[' + index + '].id'" v-bind:value="item.id">
                                                <input hidden="hidden" v-bind:name="'bundles[' + index + '].masterBundleId'" v-bind:value="item.masterBundleId">
                                                <input hidden="hidden" v-bind:name="'bundles[' + index + '].type'" v-bind:value="item.type">

                                                <span class="form-control">{{item.id}}</span>
                                            </td>
                                            <td>
                                                <input hidden="hidden" v-bind:name="'bundles[' + index + '].itemId'" v-bind:value="item.itemId">
                                                <span class="form-control">{{item.itemId}}</span>
                                            </td>
                                            <td>
                                                <input hidden="hidden" v-bind:name="'bundles[' + index + '].sku'" v-bind:value="item.sku">
                                                <span class="form-control">{{item.sku}}</span>
                                            </td>
                                            <td>
                                                <input hidden="hidden"  v-bind:name="'bundles[' + index + '].wrapQuantity'" v-bind:value="item.wrapQuantity">
                                                <span class="form-control">{{item.wrapQuantity}}</span>
                                            </td>
                                            <td>
                                                <input hidden="hidden"  v-bind:name="'bundles[' + index + '].production'" v-bind:value="item.production">
                                                <span class="form-control">{{item.production}}</span>
                                            </td>
                                            <td>
                                                <input class="form-control" v-bind:name="'bundles[' + index + '].currentProduction'"
                                                       type="number"
                                                       v-bind:value="item.currentProduction"
                                                       v-bind:min="0"
                                                       v-bind:max="item.wrapQuantity - item.production"
                                                       v-bind:readonly="!item.isSelected"
                                                       >
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <div>
                            <button class="btn btn-primary" type="submit">Receive Inventory</button>
                            <a th:href="@{/stitching/stitching-offline-items}" class="btn btn-light">Cancel</a>
                        </div>
                    </form>
                    <script th:inline="javascript">
                    </script>
                    <script th:src="@{/js/vendor/compressor.min.js}"></script>
                    <script th:src="@{/js/stitching/create-finished-item.js}"></script>
                </div>
            </main>
        </div>
        <div th:replace="_fragments :: page-footer-scripts"></div>
    </body>
</html>