<?php $__env->startSection('header'); ?>
    <?php echo e(trans('admin.head.users')); ?>


    &nbsp;&nbsp;

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

<?php $__env->startSection('main'); ?>
    <div class="row">

        <div class="col-md-12">
            <a target="_blank" href="<?php echo e(route('admin.user.export', ['format' => 'csv'])); ?>" class="btn btn-default">Export as .csv</a>
        </div>

        <div class="col-md-12">
            <hr/>
        </div>

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

            <div class="panel">
                <div class="table-primary">
                    <table class="table table-striped table-bordered" id="users-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.full_name')); ?></th>
                            <th><?php echo e(trans('admin.fields.nickname')); ?></th>
                            <th><?php echo e(trans('admin.fields.email')); ?></th>
                            <th><?php echo e(trans('admin.fields.phone')); ?></th>
                            <th><?php echo e(trans('admin.fields.total_capsules')); ?></th>
                            <th><?php echo e(trans('admin.fields.total_friends')); ?></th>
                            <th><?php echo e(trans('admin.fields.is_active')); ?></th>
                            <th><?php echo e(trans('admin.fields.is_private')); ?></th>
                            <th><?php echo e(trans('admin.user.is_suggested')); ?></th>
                            <th><?php echo e(trans('admin.fields.updated')); ?></th>
                            <th></th>
                        </tr>
                        </thead>
                        <tbody>
                        </tbody>
                        <tfoot>
                            <tr>
                                <th class="column-searchable"><input class="form-control table-footer-search" /></th>
                                <th class="column-searchable"><input class="form-control table-footer-search" /></th>
                                <th class="column-searchable"><input class="form-control table-footer-search" /></th>
                                <th class="column-searchable"><input class="form-control table-footer-search" /></th>
                                <th class="column-searchable"><input class="form-control table-footer-search" /></th>
                                <th class="column-searchable"><input class="form-control table-footer-search" /></th>
                                <th class="column-searchable"><input class="form-control table-footer-search" /></th>
                                <th class="column-searchable"><input class="form-control table-footer-search" /></th>
                                <th class="column-searchable"><input class="form-control table-footer-search" /></th>
                                <th class="column-searchable"><input class="form-control table-footer-search" /></th>
                                <th class="column-searchable"><input class="form-control table-footer-search" /></th>
                                <th class="column-searchable"><input class="form-control table-footer-search" /></th>
                                <th></th>
                            </tr>
                        </tfoot>
                    </table>
                </div>
            </div>
        </div>
    </div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('scripts'); ?>
    <style>
        th{
            vertical-align: center;
        }
        td{
            vertical-align: center;
        }
    </style>
    <script>
        $(function() {
            var users_table = $('#users-table').DataTable({
                "processing": true,
                "serverSide": true,
                "pageLength": 20,
                "lengthMenu": [[15, 30], [15, 30]],
                "order": [[ 0, "desc" ]],
                "ajax": {
                    "url": "<?php echo e(route('admin.user.list')); ?>"
                },
                "columns": [
                    {data: 'id', name: 'user.id'},
                    {data: 'uuid', name: 'user.uuid'},
                    {data: 'full_name', name: 'full_name'},
                    {data: 'nickname', name: 'user.nickname'},
                    {data: 'email', name: 'user.email'},
                    {data: 'phone_number', name: 'user.phone_number'},
                    {data: 'count_capsules', name: 'count_capsules'},
                    {data: 'count_friends', name: 'user.count_friends'},
                    {data: 'is_active', name: 'is_active'},
                    {data: 'is_private', name: 'is_private'},
                    {data: 'is_suggested', name: 'is_suggested'},
                    {data: 'updated_at', name: 'user.updated_at'},
                    {
                        data: 'id',
                        name: 'id',
                        render: function (data, type, row) {

                            <?php if( $managerPermissions->contains('value', 'users.full') ): ?>
                            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-warning block-user' href='" + row.blockLink + "'><?php echo e(__('admin.user.block')); ?></a>" +
                                    "<a class='btn btn-xs btn-danger delete-user' href='" + row.deleteLink + "'><?php echo e(__('admin.buttons.delete')); ?></a>";
                            <?php elseif( $managerPermissions->contains('value', 'users.data') ): ?>
                            return "<a class='btn btn-xs btn-info' href='" + row.showLink + "'><?php echo e(__('admin.buttons.show')); ?></a>";
                            <?php endif; ?>
                        },
                        orderable: false,
                        searchable: false
                    }
                ],
                "initComplete": function () {
                    this.api().columns().every(function () {
                        var column = this;
                        var column_class = column.footer().className;
                        if (column_class === 'column-searchable') {
                            var input = $(column.footer()).find('input');

                            input.on('change', function () {
                                column.search($(this).val(), false, false, true).draw();
                            });
                        }
                    });
                }
            });

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

                if (confirm('<?php echo e(__('admin.user.ask.block')); ?>')) {
                    $.ajax({
                        url: $(this).attr('href'),
                        type: 'GET',
                        dataType: 'json',
                        data: { method: '_GET' }
                    }).always(function (result) {
                        if (typeof result.status !== 'undefined' && result.status === 'success') {
                            users_table.draw();
                        }
                    })
                }
            });

            $(document).on('click', '.delete-user', function (e) {
                e.preventDefault();

                if (confirm('<?php echo e(__('admin.user.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') {
                            users_table.draw(false);
                        }
                    });
                }
            });
            <?php endif; ?>
        });
    </script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('admin._layout.layout', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /var/www/html/resources/views.admin/admin/user/list.blade.php ENDPATH**/ ?>