<!-- resources/views/student/index.blade.php -->

@extends('layouts/contentNavbarLayout')

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

@section('content')
<!-- Your existing content goes here -->
<h4 class="fw-bold py-3 mb-4">
    <span class="text-muted fw-light">Tables Student</span>
</h4>

<div class="card">
    <h5 class="card-header">Student</h5>
    <div class="mx-3 text-start">
        <a href="{{ route('student.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('student.export')}}?output=excel">Excel</a></li>
                <li><a class="dropdown-item" href="{{route('student.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>Nama</th>
                    <th>NIK</th>
                    <th>Tanggal Lahir</th>
                    <th>Jenis Kelamin</th>
                    <th>Agama</th>
                    <th>Jenjang</th>
                    <th>Alamat</th>
                    <th>Nama Ortu</th>
                    <th>No.Hp</th>
                    <th>Pekerjaan Ortu</th>
                    <th>Kelas</th>
                    <th>Status</th>
                    <th>Actions</th>
                </tr>
            </thead>
            <tbody>
                @foreach ($siswa as $record)
                    <tr>
                        <th scope="row">{{$loop->index + 1}}</th>
                        <td>{{$record->nama}}</td>
                        <td>{{$record->nik}}</td>
                        <td>{{$record->tgl_lahir}}</td>
                        <td>{{$record->jenkel}}</td>
                        <td>{{$record->agama}}</td>
                        <td>{{$record->jenjang}}</td>
                        <td>{{$record->alamat}}</td>
                        <td>{{$record->nama_ortu}}</td>
                        <td>{{$record->no_telp}}</td>
                        <td>{{$record->kerja_ortu}}</td>
                        <td>{{$record->level}}</td>
                        <td>
                            @if ($record->active)
                                <a href="/api/account/change-status/{{$record->user_id}}" class="btn btn-success"><i
                                        class="bx bx-lock-open-alt bx-tada-hover"></i></a>
                            @else
                                <a href="/api/account/change-status/{{$record->user_id}}" class="btn btn-danger"><i
                                        class="bx bx-lock-alt bx-tada-hover"></i></a>
                            @endif
                        </td>
                        <td>
                            <div class="btn-group" role="group" aria-label="Actions">
                                <a href="{{route('student.edit', $record->sid)}}" class="btn btn-blue"><i
                                        class="bx bx-edit-alt"></i> Edit</a>
                                <form action="{{route('student.delete', $record->sid)}}" 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>
</div>
@endsection