@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 card-outline card-warning">
                    <div class="card-header">
                        <a href="{{ route('periods.create') }}" class="btn btn-sm btn-warning button-cek-permission" data-permission="periods.create">
                            <i class="fas fa-plus"></i> Tambah Periode
                        </a>
                    </div>
                    <div class="card-body">
                        <div class="table-responsive">
                            <table id="periodsTable" class="table table-hover table-sm">
                                <thead class="bg-warning">
                                    <tr>
                                        <th width="50">No</th>
                                        <th>Kode</th>
                                        <th>Nama</th>
                                        <th>Deskripsi</th>
                                        <th width="100">Status</th>
                                        <th width="150">Dibuat</th>
                                    </tr>
                                </thead>
                                <tbody>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>

<script>
    $(document).ready(function() {
        // Initialize DataTable
        var table = $('#periodsTable').DataTable({
            processing: true,
            serverSide: true,
            ajax: {
                url: "{{ route('periods.index') }}",
                type: 'GET'
            },
            columns: [{
                    data: 0,
                    name: 'no',
                    orderable: false,
                    searchable: false
                },
                {
                    data: 1,
                    name: 'code'
                },
                {
                    data: 2,
                    name: 'name'
                },
                {
                    data: 3,
                    name: 'description'
                },
                {
                    data: 4,
                    name: 'status',
                    orderable: false
                },
                {
                    data: 5,
                    name: 'created_at'
                }
            ],
            order: [
                [1, 'asc']
            ],
            pageLength: 25,
            responsive: false,
            language: {
                processing: "Memuat...",
                search: "Cari:",
                lengthMenu: "Tampilkan _MENU_ data",
                info: "Menampilkan _START_ sampai _END_ dari _TOTAL_ data",
                infoEmpty: "Menampilkan 0 sampai 0 dari 0 data",
                infoFiltered: "(difilter dari _MAX_ total data)",
                paginate: {
                    first: "Pertama",
                    last: "Terakhir",
                    next: "Selanjutnya",
                    previous: "Sebelumnya"
                }
            }
        });
    });
</script>
@endsection