<?php $__env->startSection('title', 'হাজিরা ড্যাশবোর্ড'); ?>

<?php $__env->startSection('content'); ?>
<div class="container-fluid">
    <!-- Statistics Cards -->
    <div class="row">
        <div class="col-lg-4 col-6">
            <div class="small-box bg-info">
                <div class="inner">
                    <h3><?php echo e($stats['total_students'] ?? 0); ?></h3>
                    <p>মোট ছাত্র/ছাত্রী</p>
                </div>
                <div class="icon">
                    <i class="fa fa-users"></i>
                </div>
            </div>
        </div>
        
        <div class="col-lg-4 col-6">
            <div class="small-box bg-success">
                <div class="inner">
                    <h3><?php echo e($stats['present_today'] ?? 0); ?></h3>
                    <p>আজকে উপস্থিত</p>
                </div>
                <div class="icon">
                    <i class="fa fa-check-circle"></i>
                </div>
            </div>
        </div>
        
        <div class="col-lg-4 col-6">
            <div class="small-box bg-warning">
                <div class="inner">
                    <h3><?php echo e($stats['late_today'] ?? 0); ?></h3>
                    <p>আজকে বিলম্বে</p>
                </div>
                <div class="icon">
                    <i class="fa fa-clock"></i>
                </div>
            </div>
        </div>
        
        <div class="col-lg-4 col-6">
            <div class="small-box bg-danger">
                <div class="inner">
                    <h3><?php echo e($stats['absent_today'] ?? 0); ?></h3>
                    <p>আজকে অনুপস্থিত</p>
                </div>
                <div class="icon">
                    <i class="fa fa-user-slash"></i>
                </div>
            </div>
        </div>
        
        <div class="col-lg-4 col-6">
            <div class="small-box bg-primary">
                <div class="inner">
                    <h3><?php echo e($stats['active_cards'] ?? 0); ?></h3>
                    <p>সক্রিয় কার্ড</p>
                </div>
                <div class="icon">
                    <i class="fa fa-id-card"></i>
                </div>
            </div>
        </div>
        
        <div class="col-lg-4 col-6">
            <div class="small-box bg-secondary">
                <div class="inner">
                    <h3><?php echo e($stats['online_devices'] ?? 0); ?></h3>
                    <p>অনলাইন ডিভাইস</p>
                </div>
                <div class="icon">
                    <i class="fa fa-server"></i>
                </div>
            </div>
        </div>
    </div>

    <!-- Class Wise Attendance -->
    <div class="row mt-4">
        <div class="col-12">
            <div class="card">
                <div class="card-header bg-primary text-white">
                    <h5 class="mb-0"><i class="fa fa-chart-bar"></i> শ্রেণি ভিত্তিক উপস্থিতি (<?php echo e(date('d-m-Y')); ?>)</h5>
                </div>
                <div class="card-body">
                    <div class="table-responsive">
                        <table class="table table-bordered table-striped">
                            <thead class="bg-secondary text-white">
                                <tr>
                                    <th>শ্রেণি</th>
                                    <th>শাখা</th>
                                    <th>মোট ছাত্র</th>
                                    <th>উপস্থিত</th>
                                    <th>অনুপস্থিত</th>
                                    <th>উপস্থিতির হার</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php $__empty_1 = true; $__currentLoopData = $classWiseAttendance; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $class): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                <?php
                                    $absent = $class->total - $class->present;
                                    $percentage = $class->total > 0 ? round(($class->present / $class->total) * 100, 2) : 0;
                                ?>
                                <tr>
                                    <td><?php echo e($class->class_name_bn ?? 'ক্লাস'); ?></td>
                                    <td><?php echo e($class->section ?? '-'); ?></td>
                                    <td class="text-center"><?php echo e($class->total); ?></td>
                                    <td class="text-center text-success"><?php echo e($class->present); ?></td>
                                    <td class="text-center text-danger"><?php echo e($absent); ?></td>
                                    <td class="text-center">
                                        <div class="progress" style="height: 20px;">
                                            <div class="progress-bar bg-success" style="width: <?php echo e($percentage); ?>%">
                                                <?php echo e($percentage); ?>%
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                <tr>
                                    <td colspan="6" class="text-center">কোনো তথ্য নেই</td>
                                </tr>
                                <?php endif; ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Recent Attendances -->
    <div class="row mt-4">
        <div class="col-12">
            <div class="card">
                <div class="card-header bg-info text-white">
                    <h5 class="mb-0"><i class="fa fa-history"></i> সাম্প্রতিক হাজিরা</h5>
                </div>
                <div class="card-body">
                    <div class="table-responsive">
                        <table class="table table-bordered table-striped">
                            <thead class="bg-secondary text-white">
                                <tr>
                                    <th>সময়</th>
                                    <th>নাম</th>
                                    <th>ধরন</th>
                                    <th>কার্ড</th>
                                    <th>স্ট্যাটাস</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php $__empty_1 = true; $__currentLoopData = $recentAttendances; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $attendance): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                <tr>
                                    <td><?php echo e($attendance->check_in_time ? $attendance->check_in_time->format('h:i A') : '-'); ?></td>
                                    <td>
                                        <?php if($attendance->student): ?>
                                            <?php echo e($attendance->student->name_bn); ?>

                                        <?php elseif($attendance->teacher): ?>
                                            <?php echo e($attendance->teacher->name_bn); ?>

                                        <?php else: ?>
                                            অজানা
                                        <?php endif; ?>
                                    </td>
                                    <td>
                                        <?php if($attendance->student): ?>
                                            <span class="badge badge-primary">ছাত্র</span>
                                        <?php elseif($attendance->teacher): ?>
                                            <span class="badge badge-success">শিক্ষক</span>
                                        <?php endif; ?>
                                    </td>
                                    <td><?php echo e($attendance->card->card_uid ?? '-'); ?></td>
                                    <td>
                                        <?php if($attendance->status == 'present'): ?>
                                            <span class="badge badge-success">উপস্থিত</span>
                                        <?php elseif($attendance->status == 'late'): ?>
                                            <span class="badge badge-warning">বিলম্বে</span>
                                        <?php elseif($attendance->status == 'absent'): ?>
                                            <span class="badge badge-danger">অনুপস্থিত</span>
                                        <?php else: ?>
                                            <span class="badge badge-secondary"><?php echo e($attendance->status); ?></span>
                                        <?php endif; ?>
                                    </td>
                                </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                <tr>
                                    <td colspan="5" class="text-center">আজকে কোনো হাজিরা নেই</td>
                                </tr>
                                <?php endif; ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Devices List -->
    <?php if($devices->count() > 0): ?>
    <div class="row mt-4">
        <div class="col-12">
            <div class="card">
                <div class="card-header bg-warning">
                    <h5 class="mb-0"><i class="fa fa-microchip"></i> হাজিরা ডিভাইস সমূহ</h5>
                </div>
                <div class="card-body">
                    <div class="table-responsive">
                        <table class="table table-bordered table-sm">
                            <thead class="bg-secondary text-white">
                                <tr>
                                    <th>ডিভাইস নাম</th>
                                    <th>টাইপ</th>
                                    <th>লোকেশন</th>
                                    <th>স্ট্যাটাস</th>
                                    <th>সর্বশেষ অনলাইন</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php $__currentLoopData = $devices; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $device): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <tr>
                                    <td><?php echo e($device->device_name); ?></td>
                                    <td><?php echo e($device->device_type); ?></td>
                                    <td><?php echo e($device->location); ?></td>
                                    <td>
                                        <?php if($device->status == 'online'): ?>
                                            <span class="badge badge-success">অনলাইন</span>
                                        <?php elseif($device->status == 'offline'): ?>
                                            <span class="badge badge-danger">অফলাইন</span>
                                        <?php else: ?>
                                            <span class="badge badge-warning">রক্ষণাবেক্ষণ</span>
                                        <?php endif; ?>
                                    </td>
                                    <td><?php echo e($device->last_online ? $device->last_online->diffForHumans() : 'নেই'); ?></td>
                                </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <?php endif; ?>

    <!-- Quick Actions -->
    <div class="row mt-4">
        <div class="col-12">
            <div class="card">
                <div class="card-header bg-success text-white">
                    <h5 class="mb-0"><i class="fa fa-bolt"></i> দ্রুত অ্যাকশন</h5>
                </div>
                <div class="card-body">
                    <a href="<?php echo e(route('attendance.cards')); ?>" class="btn btn-primary">
                        <i class="fa fa-id-card"></i> কার্ড সমূহ
                    </a>
                    <a href="<?php echo e(route('attendance.devices')); ?>" class="btn btn-info">
                        <i class="fa fa-microchip"></i> ডিভাইস সমূহ
                    </a>
                    <a href="<?php echo e(route('attendance.manual')); ?>" class="btn btn-warning">
                        <i class="fa fa-pen"></i> ম্যানুয়াল হাজিরা
                    </a>
                    <a href="<?php echo e(route('attendance.report')); ?>?from_date=<?php echo e(date('Y-m-01')); ?>&to_date=<?php echo e(date('Y-m-d')); ?>" class="btn btn-secondary">
                        <i class="fa fa-file-alt"></i> রিপোর্ট
                    </a>
                </div>
            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/naowarin/school.naowarinternational.my.id/resources/views/attendance/index.blade.php ENDPATH**/ ?>