@extends('Admin.include.app')
@section('content')


<!-- Main content -->
<section class="content">
    <div class="container-fluid">
        <div class="row">
            <div class="col-md-12">
                <div class="row">
                    <div class="col-md-12">
                        <div class="card card-success">
                            <div class="card-header card-header-primary card-header-icon row">
                                <div class="card-icon col-md-10">
                                    <i class="fas fa-book-reader"> Result Panel</i>
                                </div>
                                <div class="col-md-2 ">
                                <a href="{{ route('role.export') }}" class="btn btn-primary float-right"><i class="fas fa-download"> Export</i></a>
                                </div>
                            </div>
                            <div class="card-body">
                                <form name="addForm" id="addForm" class="" method="POST" action="{{ route('role.multi-delete') }}">
                                    @csrf
                                    <table class="table table-striped table-bordered table-hover data-table dataTable dtr-inline" id="baseTable" style="width: 100%;">
                                        
                                        <thead style="background: darkcyan;">
                                            <tr>
                                                <th>S.No.</th>
                                                <th>Role</th>
                                                <th>Status</th>
                                                <th>Action</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                        </tbody>
                                    </table>
                                </form>
                            </div>

                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- /.row -->
    </div>
    <!-- /.container-fluid -->
</section>
<!-- /.content -->


@endsection
@section('script')

<script type="text/javascript">

    $(function() {  
        $(document).on('click', '.status_btn', function() {
            var status_link = $(this).data('status_link');
            Swal.fire({
                title: 'Are you sure?',
                text: "This Status will change!",
                icon: 'warning',
                showCancelButton: true,
                confirmButtonColor: '#3085d6',
                cancelButtonColor: '#d33',
                confirmButtonText: 'Yes, change it!'
            }).then((result) => {
                if (result.isConfirmed) {
                    var status = $(this).data('next_click');
                    $.ajax({
                        url: status_link,
                        type: 'GET',
                        data:{status:status},
                        success: function(res) {
                            $('#baseTable').DataTable().clear().draw();
                        }
                    });
                }
            })
        });

        var table = $('.data-table').DataTable({
            processing: true,
            serverSide: true,
            ajax : {
                url:"{{ route('role.data') }}",
                type:"GET",
                data: function ( d ) {
                    return $.extend( {}, d, {
                    "filters": $("#searchForm").serializeArray()
                    } )
                }
            } ,
            columns: [
                
                {
                    data: 'DT_RowIndex',
                    name: 'DT_RowIndex'
                },
                {
                    data: 'name',
                    name: 'name'
                },
                
                {
                    data: 'status',
                    name: 'status',
                    orderable: false,
                    searchable: false
                },
                
                {
                    data: 'action',
                    name: 'action',
                    orderable: false,
                    searchable: false
                },
                
            ],
        });
      
    });

</script>
		
@endsection