<?php $__env->startSection('content'); ?>
<div class="row">
    <div class="col-sm-12">
        <div class="page-title-box">
            <div class="float-end">
                <a href="<?php echo e(route('settings.users.create')); ?>" class="btn btn-primary btn-sm">Create New User</a>
            </div>
            <h4 class="page-title">Users Management</h4>
        </div>
    </div>
</div>

<div class="row">
    <div class="col-12">
        <div class="card">
            <div class="card-body">
                <table id="users-table" class="table table-bordered dt-responsive nowrap" style="border-collapse: collapse; border-spacing: 0; width: 100%;">
                    <thead>
                        <tr>
                            <th>#</th>
                            <th>Name</th>
                            <th>Email</th>
                            <th>Roles</th>
                            <th>Company</th>
                            <th>Action</th>
                        </tr>
                    </thead>
                </table>
            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('scripts'); ?>
<script>
$(document).ready(function() {
    $('#users-table').DataTable({
        processing: true,
        serverSide: true,
        ajax: "<?php echo e(route('settings.users.index')); ?>",
        columns: [
            { data: 'DT_RowIndex', name: 'DT_RowIndex', orderable: false, searchable: false },
            { data: 'name', name: 'name' },
            { data: 'email', name: 'email' },
            { data: 'roles', name: 'roles', orderable: false, searchable: false },
            { data: 'company', name: 'company' },
            { data: 'action', name: 'action', orderable: false, searchable: false }
        ]
    });

    $(document).on('click', '.delete-btn', function() {
        if (confirm('Are you sure you want to delete this user?')) {
            let id = $(this).data('id');
            let url = "<?php echo e(route('settings.users.destroy', ':id')); ?>".replace(':id', id);
            
            $.ajax({
                url: url,
                type: 'DELETE',
                data: { _token: "<?php echo e(csrf_token()); ?>" },
                success: function(response) {
                    if (response.status) {
                        toastr.success(response.message);
                        $('#users-table').DataTable().ajax.reload();
                    } else {
                        toastr.error(response.message);
                    }
                }
            });
        }
    });
});
</script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/codeproh/va.laraoffice.com/app/Modules/PLATFORM/UserManagement/Providers/../Views/users/index.blade.php ENDPATH**/ ?>