@extends('layouts.app')

@section('title', 'শিক্ষক তালিকা')

@section('content')
<div class="container-fluid">
    <!-- Statistics Cards -->
    <div class="row">
        <div class="col-md-3">
            <div class="small-box bg-info">
                <div class="inner">
                    <h3>{{ $stats['total'] }}</h3>
                    <p>মোট শিক্ষক</p>
                </div>
                <div class="icon">
                    <i class="fa fa-users"></i>
                </div>
            </div>
        </div>
        <div class="col-md-3">
            <div class="small-box bg-success">
                <div class="inner">
                    <h3>{{ $stats['active'] }}</h3>
                    <p>সক্রিয় শিক্ষক</p>
                </div>
                <div class="icon">
                    <i class="fa fa-user-check"></i>
                </div>
            </div>
        </div>
        <div class="col-md-3">
            <div class="small-box bg-warning">
                <div class="inner">
                    <h3>{{ $stats['permanent'] }}</h3>
                    <p>স্থায়ী শিক্ষক</p>
                </div>
                <div class="icon">
                    <i class="fa fa-user-tie"></i>
                </div>
            </div>
        </div>
        <div class="col-md-3">
            <div class="small-box bg-primary">
                <div class="inner">
                    <h3>{{ $stats['contract'] }}</h3>
                    <p>চুক্তিভিত্তিক</p>
                </div>
                <div class="icon">
                    <i class="fa fa-file-signature"></i>
                </div>
            </div>
        </div>
    </div>

    <!-- Action Buttons -->
    <div class="row mb-3">
        <div class="col-12">
            <a href="{{ route('teachers.create') }}" class="btn btn-success">
                <i class="fa fa-plus-circle"></i> নতুন শিক্ষক নিবন্ধন
            </a>
            <a href="{{ route('teachers.attendance') }}" class="btn btn-info">
                <i class="fa fa-check-circle"></i> উপস্থিতি
            </a>
            <a href="{{ route('teachers.salary') }}" class="btn btn-primary">
                <i class="fa fa-money-bill"></i> বেতন
            </a>
            <a href="{{ route('teachers.leaves') }}" class="btn btn-warning">
                <i class="fa fa-calendar-minus"></i> ছুটি
            </a>
        </div>
    </div>

    <!-- Teacher List -->
    <div class="row">
        <div class="col-12">
            <div class="card">
                <div class="card-header bg-primary text-white">
                    <h5 class="mb-0"><i class="fa fa-chalkboard-teacher"></i> শিক্ষক তালিকা</h5>
                </div>
                <div class="card-body">
                    <div class="table-responsive">
                        <table class="table table-bordered table-striped table-hover" id="teacherTable">
                            <thead class="bg-secondary text-white">
                                <tr>
                                    <th>ছবি</th>
                                    <th>শিক্ষক আইডি</th>
                                    <th>নাম</th>
                                    <th>পদবি</th>
                                    <th>বিভাগ</th>
                                    <th>ফোন</th>
                                    <th>যোগদান</th>
                                    <th>স্ট্যাটাস</th>
                                    <th width="150">একশন</th>
                                </tr>
                            </thead>
                            <tbody>
                                @foreach($teachers as $teacher)
                                <tr>
                                    <td>
                                        @if($teacher->photo)
                                            <img src="{{ asset($teacher->photo) }}" alt="ছবি" style="width: 40px; height: 40px; border-radius: 50%;">
                                        @else
                                            <div style="width: 40px; height: 40px; border-radius: 50%; background: #ccc; line-height: 40px; text-align: center;">
                                                <i class="fa fa-user"></i>
                                            </div>
                                        @endif
                                    </td>
                                    <td>{{ $teacher->teacher_id }}</td>
                                    <td>{{ $teacher->name_bn }}</td>
                                    <td>{{ Teacher::getDesignations()[$teacher->designation] ?? $teacher->designation }}</td>
                                    <td>{{ Teacher::getDepartments()[$teacher->department] ?? $teacher->department }}</td>
                                    <td>{{ $teacher->phone }}</td>
                                    <td>{{ $teacher->joining_date->format('d-m-Y') }}</td>
                                    <td>
                                        @if($teacher->job_status == 'active')
                                            <span class="badge badge-success">সক্রিয়</span>
                                        @elseif($teacher->job_status == 'inactive')
                                            <span class="badge badge-warning">নিষ্ক্রিয়</span>
                                        @else
                                            <span class="badge badge-danger">{{ $teacher->job_status }}</span>
                                        @endif
                                    </td>
                                    <td>
                                        <a href="{{ route('teachers.show', $teacher->id) }}" class="btn btn-sm btn-info" title="বিস্তারিত">
                                            <i class="fa fa-eye"></i>
                                        </a>
                                        <a href="{{ route('teachers.edit', $teacher->id) }}" class="btn btn-sm btn-warning" title="এডিট">
                                            <i class="fa fa-edit"></i>
                                        </a>
                                        <a href="#" class="btn btn-sm btn-success" title="বেতন">
                                            <i class="fa fa-money-bill"></i>
                                        </a>
                                    </td>
                                </tr>
                                @endforeach
                            </tbody>
                        </table>
                    </div>
                    
                    <div class="mt-3">
                        {{ $teachers->links() }}
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection

@section('scripts')
<script>
    $(document).ready(function() {
        $('#teacherTable').DataTable({
            "paging": false,
            "ordering": true,
            "info": false,
            "language": {
                "search": "খুঁজুন:"
            }
        });
    });
</script>
@endsection