
<?php $__env->startSection('content'); ?>
    <?php Fun::lang()?>
    <div class="page">
        <div class=container-fluid>
            <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.manage_supplier')); ?></h3>
                            </div>
                            <div class="pull-right">
                                <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('Suppliers Create')): ?>
                                    <a onclick="getHtmlForm('<?php echo e(route('suppliers.create')); ?>','<?php echo e(__('administrator.create').' '.__('administrator.supplier')); ?>','30%')" class=" button_info"><span class="fa fa-plus"></span> <?php echo e(__('administrator.create')); ?></a>

                                <?php endif; ?>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="wrapper-table" style="margin-top: 30px">
                <table id="data_table" width="100%" class="table table-striped table-hover ">
                    <thead>
                    <tr>
                        <th>#</th>
                        <th><?php echo e(__('administrator.supplier_for')); ?></th>
                        <th><?php echo e(__('administrator.supplier_name')); ?></th>
                        <th><?php echo e(__('administrator.supplier_phone')); ?></th>
                        <th><?php echo e(__('administrator.supplier_address')); ?></th>
                        <th><?php echo e(__('administrator.created_at')); ?></th>
                        <th><?php echo e(__('administrator.action')); ?></th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php $__currentLoopData = $data; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <?php
                            $check = \App\Model\stock_inventory\PurchaseModel::where('supplier_id',$value->id)->first();
                        ?>
                        <tr>
                            <td><?php echo e($key+1); ?></td>
                            <td><?php echo e(__('administrator.'.$value->type)); ?></td>
                            <td><span class="sup_name"><?php echo e($value->supplier_name); ?></span></td>
                            <td><?php echo e($value->supplier_phone); ?></td>
                            <td><?php echo e($value->supplier_address); ?></td>
                            <td><?php echo e(date('d-m-Y', strtotime($value->created_at))); ?></td>
                            <td>
                                <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('Suppliers Edit')): ?>
                                    <a data-href="<?php echo e(route('suppliers.edit',$value->id)); ?>" class=" button_warning btn-edit"><?php echo e(__('administrator.edit')); ?>

                                    </a>
                                <?php endif; ?>
                                <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('Suppliers Show')): ?>
                                    <?php if($check): ?>
                                        <a data-href="<?php echo e(route('suppliers.show',$value->id)); ?>"
                                           class=" button_primary btn_supplier_info_public"><?php echo e(__('administrator.history')); ?></a>
                                    <?php endif; ?>
                                <?php endif; ?>
                                <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('Suppliers Delete')): ?>
                                    <?php if(!$check): ?>
                                        <a class="button_danger btn_delete"
                                           data-href="<?php echo e(route('suppliers.delete')); ?>?id=<?php echo e($value->id); ?>"><?php echo e(__('administrator.delete')); ?></a>
                                    <?php endif; ?>
                                <?php endif; ?>

                            </td>
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </tbody>
                </table>
            </div>
        </div>
        <?php $__env->stopSection(); ?>
        <?php $__env->startSection('script'); ?>

            <script type="text/javascript">
                $('#data_table').DataTable({
                    "lengthMenu":[20,30,50,100]

                });
                $('#data_table').on('click','.btn-edit',function () {
                    let href = $(this).data('href');
                    getHtmlForm(href,'<?php echo e(__('administrator.edit').' '.__('administrator.supplier')); ?>','30%')
                });
                $('#data_table').on('click', '.btn_delete', function () {
                    let text = $(this).closest('tr').find('.sup_name').text();
                    let url = $(this).data('href');
                    $.confirm({
                        theme: 'modern',
                        title: '<?php echo e(__('administrator.are_you_sure')); ?>',
                        content: 'Supplier Name :' + text,
                        buttons: {
                            delete: {
                                btnClass: 'button_danger',
                                text: '<?php echo e(__('administrator.delete')); ?>',
                                action: function () {
                                    $.ajax({
                                        method: 'get',
                                        url: url,
                                        success: function (res) {
                                            if (res) {
                                                window.location.reload();
                                            }
                                        },
                                        error: function (xhr) {
                                            alertErrorFormController(xhr);
                                        }
                                    });
                                }
                            },
                            cancel: {
                                btnClass: 'button_warning',
                                text: '<?php echo e(__('administrator.cancel')); ?>',
                                action: function () {

                                }
                            },
                        }
                    });
                });


            </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/people/suppliers/index.blade.php ENDPATH**/ ?>