@extends('layouts/contentNavbarLayout')

@section('title', 'Tables - Jadwal')

@section('content')
<h4 class="fw-bold py-3 mb-4">
    <span class="text-muted fw-light">Tables Jadwal</span>
</h4>

<!-- Responsive Table -->
<div class="card">
    <h5 class="card-header">Jadwal</h5>
    @if ($user->role == "Admin")
        <div class="mx-3 text-start">
            <a href="{{ route('jadwal.create') }}">
                <button type="submit" class="btn btn-sm btn-primary">
                    <i class='bx bx-plus'></i>
                    Add
                </button>
            </a>
            <div class="btn-group">
                <button type="button" class="btn btn-sm btn-primary dropdown-toggle" data-bs-toggle="dropdown"
                    aria-expanded="false">Export</button>
                <ul class="dropdown-menu">
                    <li><a class="dropdown-item" href="{{route('jadwal.export')}}?output=excel">Excel</a></li>
                    <li><a class="dropdown-item" href="{{route('jadwal.export')}}?output=pdf">PDF</a></li>
                </ul>
            </div>
        </div>
        <div class="table-responsive text-nowrap p-3">
            <table class="table" id="table">
                <thead>
                    <tr class="text-nowrap">
                        <th>No</th>
                        <th>Tutor</th>
                        <th>Kelas</th>
                        <th>Hari</th>
                        <th>Jam</th>
                        <th>Actions</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach ($jadwal as $record)
                        <tr>
                            <th scope="row">{{$loop->index + 1}}</th>
                            <td>{{$record->nama}}</td>
                            <td>{{$record->kelas}}</td>
                            <td>{{$record->hari}}</td>
                            <td>{{$record->jam}}</td>
                            <td>
                                <div class="btn-group" role="group" aria-label="Actions">
                                    <a href="{{route('jadwal.edit', $record->jadwal_id)}}" class="btn btn-blue"><i
                                            class="bx bx-edit-alt"></i> Edit</a>
                                    <form action="{{route('jadwal.delete', $record->jadwal_id)}}" method="POST">
                                        @csrf
                                        @method("DELETE")
                                        <button type="submit" class="btn btn-white"
                                            onclick="return confirm('Apakah Kamu Yakin?')">
                                            <i class="bx bx-trash"></i> Delete
                                        </button>
                                    </form>
                                </div>
                            </td>
                        </tr>
                    @endforeach
                </tbody>
            </table>
        </div>
    @else
        <div class="table-responsive text-nowrap p-3">
            <table class="table" id="table">
                <thead>
                    <tr class="text-nowrap">
                        <th>No</th>
                        <th>Tutor</th>
                        <th>Kelas</th>
                        <th>Hari</th>
                        <th>Jam</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach ($jadwal as $record)
                        <tr>
                            <th scope="row">{{$loop->index + 1}}</th>
                            <td>{{$record->nama}}</td>
                            <td>{{$record->kelas}}</td>
                            <td>{{$record->hari}}</td>
                            <td>{{$record->jam}}</td>
                        </tr>
                    @endforeach
                </tbody>
            </table>
        </div>
    @endif
</div>
<!--/ Responsive Table -->
@endsection