<div class="row">
    <div class="col-md-12">

        <div class="panel">
            <div class="table-primary">
                <table class="table table-striped table-bordered" id="capsule-table" width="100%">
                    <thead>
                    <tr>
                        <th><?php echo e(trans('admin.fields.id')); ?></th>
                        <th><?php echo e(trans('admin.fields.uuid')); ?></th>
                        <th><?php echo e(trans('admin.fields.caption')); ?></th>
                        <th><?php echo e(trans('admin.fields.opens')); ?></th>
                        <th><?php echo e(trans('admin.fields.created')); ?></th>
                        <?php if($managerPermissions->contains('value', 'capsules.full')): ?><th></th><?php endif; ?>
                    </tr>
                    </thead>
                    <tbody>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>

<?php $__env->startSection('scripts'); ?>
    ##parent-placeholder-16728d18790deb58b3b8c1df74f06e536b532695##

    <script>
        var capsule_table = $('#capsule-table').DataTable({
            "processing": true,
            "serverSide": true,
            "pageLength": 20,
            "lengthMenu": [[15, 30], [15, 30]],
            "order": [[ 0, "desc" ]],
            "ajax": {
                "url": "<?php echo e(route('admin.user.user_capsules.list', ['id' => $user->id])); ?>"
            },
            "columns": [
                {data: 'id', name: 'id'},
                {data: 'uuid', name: 'uuid'},
                {data: 'caption', name: 'caption'},
                {data: 'open_at', name: 'open_at'},
                {data: 'created_at', name: 'created_at'},
                <?php if($managerPermissions->contains('value', 'capsules.full')): ?>
                {
                    data: 'id',
                    name: 'id',
                    render: function (data, type, row) {
                        return "<a class='btn btn-xs btn-info' href='" + row.showLink + "'><?php echo e(__('admin.buttons.show')); ?></a>" +
                            "<a class='btn btn-xs btn-primary' href='" + row.editLink + "'><?php echo e(__('admin.buttons.edit')); ?></a>" +
                            "<a class='btn btn-xs btn-danger delete-capsule' href='" + row.deleteLink + "'><?php echo e(__('admin.buttons.delete')); ?></a>";
                    },
                    orderable: false,
                    searchable: false
                }
                <?php endif; ?>
            ]
        });

        <?php if( $managerPermissions->contains('value', 'capsules.full')): ?>
        $(document).on('click', '.delete-capsule', function (e) {
            e.preventDefault();

            if (confirm('<?php echo e(__('admin.capsule.ask.delete')); ?>')) {
                $.ajax({
                    url: $(this).attr('href'),
                    type: 'DELETE',
                    dataType: 'json',
                    data: { method: '_DELETE' }
                }).always(function (result) {
                    if (typeof result.status !== 'undefined' && result.status === 'success') {
                        capsule_table.draw(false);
                    }
                });
            }
        });
        <?php endif; ?>
    </script>
<?php $__env->stopSection(); ?><?php /**PATH /var/www/html/resources/views.admin/admin/user/lists/capsules.blade.php ENDPATH**/ ?>