
<script>
    $(document).ready(function() {

        $("#<?php echo e($table['id']); ?>").on( 'click', 'tbody td',function (e) {

        });
        console.log($main_tab_content.find('#<?php echo e($table['id']); ?>'))
        $main_tab_content.find('#<?php echo e($table['id']); ?>').on( 'click', 'tbody td>.dropdown>.dropdown-menu a.list-ajustements',function (e) {
            
        });

        $main_tab_content.find('#<?php echo e($table['id']); ?>').on( 'click', 'tbody td.qty-editable>span,' +
            ' tbody td>.dropdown>.dropdown-menu a.ajuster-stock', function (e) {
            
        } );

        $('#<?php echo e($table['id']); ?>').on( 'click', 'tbody td', function (e) {
            let tableId = "<?php echo e($table['id']); ?>";
            let table = $("#"+tableId).DataTable();
            let editor = updateRowStockEditor;
            let $td = $(this);
            let  index = $td.index();
            let rowData = table.row($td).data();
            let msg =  rowData.product.fullName;
            editor.s.table = "#"+tableId;

            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('st-adjustment-create')): ?>
                if ( index === 3 ) { // colonne 'qty'
                    //  editor = createAdjustmentEditor;
                    loadEditorCreateAdjustment(rowData,tableId)
                    // editor.s.table = "#"+tableId;
                    // editor.create();
                }
            <?php endif; ?>


            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check("st-stock-update")): ?>
                if ( index === 0 ) { // colonne 'lot_id'
                editor.s.ajax.url  = "<?php echo e(route("admin.stocks.edit.lot-id")); ?>";
                    editor.bubble( $td,["lot_id"], {
                        message: msg,
                        buttons: {
                            label: '<?php echo e(__("OK")); ?>',
                            className:"btn-primary btn-sm fs-11",
                            fn: function () {
                                this.submit(
                                    function (data) {
                                        if(typeof data === 'object' && !$.isEmptyObject(data)){
                                            if(data.success){
                                                refresh_datatable(tableId);
                                            }
                                        }
                                    },
                                );
                            },
                        },
                    } );
                }
                else if(index === 5){ // colonne 'expired_at'
                editor.s.ajax.url  = "<?php echo e(route("admin.stocks.edit.expired-at")); ?>";
                editor.bubble( $td,["expired_at"], {
                    message: msg,
                    buttons: {
                        label: '<?php echo e(__("OK")); ?>',
                        className:"btn-primary btn-sm fs-11",
                        fn: function () {
                            this.submit(
                                function (data) {
                                    if(typeof data === 'object' && !$.isEmptyObject(data)){
                                        if(data.success){
                                            refresh_datatable(tableId);
                                        }
                                    }
                                },
                            );
                        },
                    },
                } );
            }
            <?php endif; ?>

        } );

    } );
</script>
<div class="card-body">
    <div class="col-lg-12 form-group table-responsive">
        <table class="table table-striped table-bordered" id="<?php echo e($table['id']); ?>" style="width: 100%">
            <thead>
                <tr>
                    <th class="left"><?php echo e(__("Lot Id")); ?></th>
                    <th class="left"><?php echo e(__("Product Id")); ?></th>
                    <th class="left"><?php echo e(__("Product Name")); ?></th>
                    <th class="right"><?php echo e(__("Qty")); ?></th>

                    <th class="left"><?php echo e(__("Category")); ?></th>
                    <th class="left"><?php echo e(__("Expired At")); ?></th>
                    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->any(["st-adjustment-create","st-adjustment-list",])): ?>

                    <?php endif; ?>
                </tr>
            </thead>
        </table>
    </div>
</div>


<?php /**PATH /home2/lekruu/public_html/resources/views/backend/stocks/management/tabs/lots/tab-avaibles-and-all-lots.blade.php ENDPATH**/ ?>