<div>
    <div wire:ignore.self class="py-12">
        <div class="table-responsive table-item">
            <table id="example" class="my-table dataTables_wrapper dt-bootstrap5" style="width:100%; ">
                <thead>
                    <tr>
                        <th scope="col" style="border-top-left-radius: 1rem">#</th>
                        <!--[if BLOCK]><![endif]--><?php if($items->isEmpty()): ?>
                    <tr>
                        <th scope="col">Empty</th>
                    </tr>
                <?php else: ?>
                    <!--[if BLOCK]><![endif]--><?php $__currentLoopData = array_keys((array) $items[0]); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $fieldName): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <!--[if BLOCK]><![endif]--><?php if(strpos($fieldName, 'U_') === 0): ?>
                            <th scope="col"><?php echo e(ucfirst(substr($fieldName, 2))); ?></th>
                        <?php else: ?>
                            <th scope="col"><?php echo e(ucfirst(__($fieldName))); ?></th>
                        <?php endif; ?> <!--[if ENDBLOCK]><![endif]-->
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?> <!--[if ENDBLOCK]><![endif]-->
                    <?php endif; ?> <!--[if ENDBLOCK]><![endif]-->
                    </tr>
                </thead>

                <tbody class="small">
                    <!--[if BLOCK]><![endif]--><?php $__currentLoopData = $items; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <tr>
                            <th scope="row"><?php echo e($key + 1); ?></th>
                            <!--[if BLOCK]><![endif]--><?php $__currentLoopData = (array) $item; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <!--[if BLOCK]><![endif]--><?php if($key == 'info'): ?>
                                    <td>
                                        <!--[if BLOCK]><![endif]--><?php if($value === 0): ?>
                                            -
                                        <?php else: ?>
                                            <button data-bs-toggle="modal"
                                                data-bs-target="#exampleModal<?php echo e($item->code); ?>"
                                                class="btn btn-sm badge button-custom-success">PROMO</button>
                                        <?php endif; ?> <!--[if ENDBLOCK]><![endif]-->
                                    </td>
                                <?php else: ?>
                                    <td><?php echo e($value); ?></td>
                                <?php endif; ?> <!--[if ENDBLOCK]><![endif]-->
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?> <!--[if ENDBLOCK]><![endif]-->
                        </tr>
                        <div wire:ignore.self class="modal fade" id="exampleModal<?php echo e($item->code); ?>" tabindex="-1"
                            aria-labelledby="exampleModalLabel" aria-hidden="true" data-bs-backdrop="static"
                            data-bs-keyboard="false">
                            <div class="modal-dialog modal-dialog-centered">
                                <div class="modal-content">
                                    <div class="modal-header">
                                        <h5 class="modal-title" id="exampleModalLabel">Promo</h5>
                                        <button type="button" class="btn-close" data-bs-dismiss="modal"
                                            wire:click="clearPromo" aria-label="Close"></button>
                                    </div>
                                    <!--[if BLOCK]><![endif]--><?php if($promoitem): ?>
                                        <div class="modal-body">
                                            <ul>
                                                <!--[if BLOCK]><![endif]--><?php $__currentLoopData = $promoitem; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                    <li><?php echo e($item->name); ?> || Periode : <?php echo e($item->from_date); ?> -
                                                        <?php echo e($item->to_date); ?></li>
                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?> <!--[if ENDBLOCK]><![endif]-->
                                            </ul>
                                        </div>
                                    <?php else: ?>
                                    <div class="modal-body text-center">
                                        <button type="button" class="custom-button1 text-center"
                                        wire:click="dispatchToDetailItem('<?php echo e($item->code); ?>')">Check</button>
                                    </div>
                                        
                                    <?php endif; ?> <!--[if ENDBLOCK]><![endif]-->

                                    <div class="modal-footer">
                                        <button type="button" class="custom-button1" data-bs-dismiss="modal"
                                            wire:click="clearPromo">Close</button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?> <!--[if ENDBLOCK]><![endif]-->
                </tbody>
            </table>
        </div>
        <div wire:ignore.self>
            <table id="example" class="table dataTables_wrapper dt-bootstrap5" style="width:100%; ">
                <thead>
                    <tr>
                        <th scope="col">#</th>
                        <th scope="col"></th>
                        <th scope="col"></th>
                        <th scope="col"></th>
                        <th scope="col"></th>
                        <th scope="col"></th>
                        <th scope="col"></th>
                        <th scope="col"></th>
                        <th scope="col"></th>
                        <th scope="col"></th>
                        <th scope="col"></th>
                        <th scope="col"></th>
                        <th scope="col"></th>
                        <th scope="col"></th>
                        <th scope="col"></th>

                        <th style="text-align: center;" scope="col"><?php echo e(__('Total Qty')); ?></th>
                    </tr>
                </thead>

                <tbody class="small">

                    <tr>
                        <td colspan="6">Total</td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>

                        <td style="text-align: center;"><?php echo e(number_format($items->sum('qty'), 0, ',', ',')); ?></td>
                    </tr>

                </tbody>
            </table>
        </div>
    </div>
</div>
<?php echo \Livewire\Mechanisms\FrontendAssets\FrontendAssets::scripts(); ?>

<script>
    Livewire.on('refreshjs', (params) => {
        $(document).ready(function() {
            $.fn.dataTable.ext.errMode = 'none';
            var table = $('#example').DataTable();

            $(document).keypress(function(e) {
                // Check if the pressed key is '/' (forward slash)
                if (e.which == 47) {
                    e.preventDefault(); // Prevent default action
                    // Focus on the search input field of the DataTable
                    $('.dataTables_filter input').focus();
                }
                // Check if the pressed key is '.' (period) for next page
                else if (e.which == 46) {
                    e.preventDefault(); // Prevent default action
                    table.page('next').draw('page');
                }
                // Check if the pressed key is ',' (comma) for previous page
                else if (e.which == 44) {
                    e.preventDefault(); // Prevent default action
                    table.page('previous').draw('page');
                }
            });
        });
    });
</script>
<?php /**PATH C:\laragon\www\rybc\resources\views/livewire/pos/item/item-table.blade.php ENDPATH**/ ?>