@extends('layouts/base_view')
@section('title')
{!! $variables['header_routes'] !!}
@endsection
@section('content')
<section class="content">
    <div class="container-fluid">
        <div class="row">
            <div class="col-12">
                <div class="card">
                    <div class="card-header">
                        <div class="d-flex flex-wrap align-items-center">
                            <a href="{{ route('users.create') }}" class="btn btn-sm btn-warning mb-2 mb-md-0 mr-2 button-cek-permission" data-permission="users.create" data-toggle="tooltip" title="Tambah Baru">
                                <i class="fas fa-plus"></i><span class="d-none d-sm-inline ml-1">Tambah</span>
                            </a> 
                            <a href="{{ route('users.session_management') }}" class="btn btn-sm btn-warning mb-2 mb-md-0 mr-2 button-cek-permission" data-permission="users.session_management" data-toggle="tooltip" title="Manajemen Session">
                                <i class="fas fa-gear"></i><span class="d-none d-sm-inline ml-1">Manajemen Session</span>
                            </a> 
                        </div>
                        <!-- <div class="row">
                            <div class="col-md-2 mr">
                                <a href="{{ route('users.create') }}" class="btn btn-warning btn-block btn-sm button-cek-permission" data-permission="users.create">
                                    <i class="fas fa-plus"></i> Tambah
                                </a>
                                <a href="{{ route('users.create') }}" class="btn btn-warning btn-block btn-sm button-cek-permission" data-permission="users.create">
                                    <i class="fas fa-plus"></i> Tambah
                                </a>
                            </div>
                        </div> -->
                    </div>
                    <div class="card-body">
                        <!-- <table id="id_data_table"  <table id="id_data_table" class="table table-hover table-sm"> -->
                        <table id="id_data_table" class="table table-hover table-sm">
                            <thead class="bg-warning">
                                <tr>
                                    <th width="5%">No</th>
                                    <th>Username</th>
                                    <th>Nama Lengkap</th>
                                    <th>Email</th>
                                    <th>Roles</th>
                                    <th>Status</th>
                                    <th width="15%">Dibuat</th> 
                                </tr>
                            </thead>
                            <tbody>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>

<form action="" id="delete-form" method="post">
    @method('delete')
    @csrf
</form>
<script>
    $(function() {
        $('#id_data_table').DataTable({
            processing: true,
            serverSide: true,
            ajax: '{{ route("users.index") }}',
            columns: [{
                    data: 0,
                    name: 'no',
                    orderable: false,
                    searchable: false
                },
                {
                    data: 1,
                    name: 'username'
                },
                {
                    data: 2,
                    name: 'fullname'
                },
                {
                    data: 3,
                    name: 'email'
                },
                {
                    data: 4,
                    name: 'roles',
                    orderable: false,
                    searchable: false
                },
                {
                    data: 5,
                    name: 'status'
                },
                {
                    data: 6,
                    name: 'created_at'
                }
            ],
            "responsive": false,
            "lengthChange": true,
            "autoWidth": false,
            //"buttons": ["copy", "csv", "excel", "pdf", "print", "colvis"],
            drawCallback: function(settings) {
                $('[data-toggle="tooltip"]').tooltip(); // Re-initialize tooltip setiap kali tabel di-redraw
            }
        }).buttons().container().appendTo('#id_data_table_wrapper .col-md-6:eq(0)');

    });
</script>
@endsection