@extends('layouts.app')

@section('content')
<div class="max-w-full mx-auto px-4 sm:px-6 lg:px-8">
    <div class="bg-white overflow-hidden shadow sm:rounded-lg">
        <div class="px-4 py-5 sm:px-6">
            <h3 class="text-xl leading-6 font-semibold text-gray-900">
                All Responses
            </h3>
        </div>
        <div class="px-4 py-5 sm:px-6">
            <!-- <div class="overflow-x-auto w-full"> -->
            <div class="overflow-x-auto w-full max-w-screen-lg mx-auto">
                <table id="responses-table" class="table-auto w-full table-striped border-collapse border border-gray-200 rounded-lg">
                    <thead class="bg-gray-100">
                        <tr>
                            <th class="px-4 py-2 border border-gray-200">ID</th>
                            <th class="px-4 py-2 border border-gray-200">Title</th>
                            <th class="px-4 py-2 border border-gray-200">Organising Institute</th>
                            <th class="px-4 py-2 border border-gray-200">Address</th>
                            <th class="px-4 py-2 border border-gray-200">Department</th>
                            <th class="px-4 py-2 border border-gray-200">Faculty</th>
                            <th class="px-4 py-2 border border-gray-200">Start Date</th>
                            <th class="px-4 py-2 border border-gray-200">Start Time</th>
                            <th class="px-4 py-2 border border-gray-200">End Date</th>
                            <th class="px-4 py-2 border border-gray-200">End Time</th>
                            <th class="px-4 py-2 border border-gray-200">Num Days</th>
                            <th class="px-4 py-2 border border-gray-200">Activity Type</th>
                            <th class="px-4 py-2 border border-gray-200">Category</th>
                            <th class="px-4 py-2 border border-gray-200">Level</th>
                            <!-- <th class="px-4 py-2 border border-gray-200">Faculty</th> -->
                            <th class="px-4 py-2 border border-gray-200">Proof</th>
                        </tr>
                    </thead>
                    <tbody>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>

@endsection

@section('scripts')
<!-- DataTables JS -->

<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.13.1/css/jquery.dataTables.min.css">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.13.1/css/dataTables.bootstrap5.min.css">
<script src="https://code.jquery.com/jquery-3.5.1.js"></script>
<script src="https://cdn.datatables.net/1.13.1/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.13.1/js/dataTables.bootstrap5.min.js"></script>

<!-- <link rel="stylesheet" href="https://cdn.datatables.net/1.12.1/css/dataTables.bootstrap5.min.css">
<script src="https://code.jquery.com/jquery-3.5.1.js"></script>
<script src="https://cdn.datatables.net/1.12.1/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.12.1/js/dataTables.bootstrap5.min.js"></script> -->
<script>
    $(document).ready(function() {
        var initAjaxRoute = function(route) {
            table = $("#responses-table").DataTable({
                fnDestroy: true,
                processing: true,
                serverSide: true,
                responsive: true,
                ajax: {
                    url: route,
                },
                columns: [
                    { data: 'id', name: 'id', },
                    { data: 'title', name: 'title', orderable: false},
                    { data: 'organising_institute', name: 'organising_institute', orderable: false },
                    { data: 'address', name: 'address' , orderable: false},
                    { data: 'department_name', name: 'department' , orderable: false},
                    { data: 'user_name', name: 'user_name', orderable: false },
                    { data: 'start_date', name: 'start_date', orderable: false },
                    { data: 'start_time', name: 'start_time', orderable: false },
                    { data: 'end_date', name: 'end_date', orderable: false },
                    { data: 'end_time', name: 'end_time', orderable: false },
                    { data: 'num_days', name: 'num_days', orderable: false },
                    { data: 'activity_type', name: 'activity_type', orderable: false },
                    { data: 'category', name: 'category', orderable: false },
                    { data: 'level', name: 'level', orderable: false },
                    { data: 'action', name: 'proof', orderable: false, searchable: false }, // View button for proof
                ],
                columnDefs: [
                {
                    targets: 0, 
                    // width: '170px', 
                    className: 'text-center wrap-text', 
                },
                {
                    targets: 1, 
                    // width: '150px', 
                    className: 'text-center wrap-text', 
                },
                {
                    targets: 2, 
                    // maxWidth: '150px', 
                    className: 'text-center wrap-text', 
                },
                {
                    targets: 3, 
                    // maxWidth: '100px', 
                    className: 'text-center wrap-text', 
                },
                {
                    targets: 4, 
                    // maxWidth: '300px', 
                    className: 'text-center wrap-text', 
                },
                {
                    targets: 5, 
                    // maxWidth: '150px', 
                    className: 'text-center wrap-text', 
                },
                {
                    targets: 6, 
                    // maxWidth: '100px', 
                    className: 'text-center wrap-text', 
                },
                {
                    targets: 7, 
                    // maxWidth: '100px', 
                    className: 'text-center wrap-text', 
                },
                {
                    targets: 8, 
                    // width: '100px', 
                    className: 'text-center wrap-text', 
                },
                {
                    targets: 9, 
                    // width: '50px', 
                    className: 'text-center wrap-text', 
                },
                {
                    targets: 10, 
                    // width: '120px', 
                    className: 'text-center wrap-text', 
                },
                {
                    targets: 11, 
                    // width: '120px', 
                    className: 'text-center wrap-text', 
                },
            ],
                // order: [[4, 'asc']],
            });
        };

        initAjaxRoute("{{ route('coordinator.ActivitiesAttendedResponses.data') }}");
    });
</script>

@endsection