<?php $__env->startSection('content'); ?>
    <?php Fun::lang()?>
    <div class="container-fluid">
        <div class="">
            <div class="top-content">
                <div class="row">
                    <div class="col-sm-12 col-xs-12">
                        <div class="title-add">
                            <div class="pull-left">
                                <h3><?php echo e(__('administrator.fabric')); ?> </h3>
                            </div>
                            <div class="pull-right">
                            <?php if(Gate::check('Fabric create')): ?>
                                <a href="<?php echo e(route('fabric.create')); ?>" class=" button_primary"><span class="fa fa-plus"></span> <?php echo e(__('administrator.create')); ?></a>
                                <a data-name="Import" data-href="<?php echo e(route('fabric-import-exel')); ?>" data-width="800px" class="button_info getHtmlForm"><span class="fa fa-upload"></span> <?php echo e(__('administrator.import')); ?></a>
                            <?php endif; ?>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="wrapper-table">
                <table id="datatable_products" class="table  table-striped table-hover">
                    <thead>
                    <tr>
                        <th>#</th>
                        <th><?php echo e(__('administrator.barcode')); ?></th>
                        <th><?php echo e(__('administrator.fabric')); ?></th>
                        <th><?php echo e(__('administrator.color')); ?></th>
                        <th><?php echo e(__('administrator.image')); ?></th>
                        <th><?php echo e(__('administrator.category')); ?></th>
                        <th><?php echo e(__('administrator.unit')); ?></th>
                        <th><?php echo e(__('administrator.cost')); ?></th>
                        <th><?php echo e(__('administrator.created_at')); ?></th>
                        <th><?php echo e(__('administrator.action')); ?></th>
                    </tr>
                    </thead>
                    <tbody>

                    </tbody>
                </table>
            </div>
        </div>
    </div>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('script'); ?>
    <script type="text/javascript">
        $(document).ready(function () {
            $('#datatable_products').on('click', '.delete', function () {
                let _this = $(this);
                let url = _this.data('url');
                $.confirm({
                    'title':'<?php echo e(__('administrator.delete')); ?>',
                    'content':'<?php echo e(__('administrator.are_you_sure')); ?>',
                    'theme':'modern',
                    buttons:{
                        delete:{
                            btnClass:'button_danger',
                            text:'<?php echo e(__('administrator.delete')); ?>',
                            action:function () {
                                $.ajax({
                                    url: url,
                                    async: false,
                                    success:function (data) {
                                            if(data==='ok'){
                                                _this.closest('tr').remove();
                                            }
                                    }
                                });
                            }
                        },
                        cancel:{
                            btnClass:'button_warning',
                            text:'<?php echo e(__('administrator.cancel')); ?>',
                            action:function () {

                            }
                        },
                    }
                });
            });
            $(document).on('click', '.edit', function () {
                window.location.href = $(this).data('url');
            });
            $('#datatable_products').DataTable({
                ordering: true,
                serverSide: true,
                lengthMenu: [[20, 30, 50, 100, 200, 500, 1000], [20, 30, 50, 100, 200, 500, 1000]],
                ajax: "<?php echo e(route('fabric.index')); ?>",
                columns:
                    [
                        {data: 'DT_RowIndex',searchable:false, "orderable": "false"},
                        {data: 'barcode', 'name': 'nso007_products.barcode'},
                        {data: 'product_name', 'name': 'nso007_products.product_name'},
                        {data: 'color_code', 'searchable': false},
                        { data: 'images','searchable': false,
                            render: function( data, type, full, meta ) {
                                return "<div class=\"popover__wrapper\"><img src=\"" + data + "\" width=\"30\"/><div class=\"popover__content\"><img src=\"" + data + "\" width=\"350\"/></div></div>";
                            }
                        },
                        {data: 'category_id', 'searchable': false},
                        {data: 'unit_id', 'searchable': false},
                        {data: 'cost_usd', 'searchable': false},
                        {data: 'created_at', 'searchable': false},
                        {data: 'action', 'searchable': false},

                    ],


                "initComplete": function (settings, json) {
                }

            });
        });

    </script>
<?php $__env->stopSection(); ?>



<?php echo $__env->make(branchMenu(), \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/nsowos/public_html/shr-brand/resources/views/administrator/setup-item/product-fabric/index.blade.php ENDPATH**/ ?>