<?php $__env->startSection('title', 'Teacher Attendance'); ?>
<?php $__env->startSection('page_title', 'Teacher / Staff Attendance'); ?>
<?php $__env->startSection('breadcrumbs'); ?>
    <li class="breadcrumb-item"><a href="<?php echo e(route('dashboard')); ?>">Home</a></li>
    <li class="breadcrumb-item active">Teacher Attendance</li>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('page_actions'); ?>
    <a href="<?php echo e(route('attendance.teachers.report')); ?>" class="btn btn-outline-primary"><i class="bi bi-bar-chart me-1"></i>Monthly Report</a>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
    <div class="card mb-3"><div class="card-body">
        <form method="GET" class="row g-2 align-items-end">
            <div class="col-md-3"><label class="form-label small">Date</label>
                <input type="date" name="date" value="<?php echo e($date); ?>" class="form-control form-control-sm"></div>
            <div class="col-md-3"><button class="btn btn-sm btn-primary"><i class="bi bi-search me-1"></i>Load</button></div>
        </form>
    </div></div>

    <?php if($staff->isNotEmpty()): ?>
        <form method="POST" action="<?php echo e(route('attendance.teachers.store')); ?>">
            <?php echo csrf_field(); ?>
            <input type="hidden" name="date" value="<?php echo e($date); ?>">
            <div class="card">
                <div class="card-header d-flex justify-content-between align-items-center">
                    <span><i class="bi bi-person-workspace me-1"></i><?php echo e($staff->count()); ?> staff &mdash; <?php echo e(\Illuminate\Support\Carbon::parse($date)->format('d M Y')); ?></span>
                    <button type="button" class="btn btn-sm btn-light border" id="markAllPresent"><i class="bi bi-check2-all me-1"></i>Mark all present</button>
                </div>
                <div class="card-body">
                    <table class="table table-hover align-middle">
                        <thead><tr><th>Staff</th><th>Role</th><th>Status</th><th>Remarks</th></tr></thead>
                        <tbody>
                            <?php $__currentLoopData = $staff; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $member): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <?php $rec = $existing->get($member->id); $cur = $rec?->status ?? 'present'; ?>
                                <tr>
                                    <td><div class="d-flex align-items-center gap-2"><span class="sms-avatar sm"><?php echo e($member->initials); ?></span><div><div class="fw-semibold"><?php echo e($member->name); ?></div><div class="small text-muted"><?php echo e($member->employee_code ?? $member->email); ?></div></div></div></td>
                                    <td><span class="badge bg-soft-info"><?php echo e($member->role_label); ?></span></td>
                                    <td style="min-width:210px">
                                        <div class="btn-group btn-group-sm" role="group">
                                            <?php $__currentLoopData = App\Models\TeacherAttendance::STATUSES; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $st): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <input type="radio" class="btn-check" name="status[<?php echo e($member->id); ?>]" id="t<?php echo e($member->id); ?>_<?php echo e($st); ?>" value="<?php echo e($st); ?>" <?php if($cur===$st): echo 'checked'; endif; ?>>
                                                <label class="btn btn-outline-<?php echo e(App\Models\TeacherAttendance::statusColor($st)); ?>" for="t<?php echo e($member->id); ?>_<?php echo e($st); ?>"><?php echo e(ucfirst($st)); ?></label>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        </div>
                                    </td>
                                    <td><input type="text" name="remarks[<?php echo e($member->id); ?>]" value="<?php echo e($rec?->remarks); ?>" class="form-control form-control-sm" placeholder="—"></td>
                                </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </tbody>
                    </table>
                </div>
                <div class="card-footer text-end"><button class="btn btn-primary"><i class="bi bi-save me-1"></i>Save Attendance</button></div>
            </div>
        </form>
        <?php $__env->startPush('scripts'); ?>
        <script>document.getElementById('markAllPresent').addEventListener('click',()=>document.querySelectorAll('input[id$="_present"]').forEach(r=>r.checked=true));</script>
        <?php $__env->stopPush(); ?>
    <?php else: ?>
        <div class="card"><div class="card-body text-center text-muted py-4">No staff found for this branch.</div></div>
    <?php endif; ?>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/u385418287/domains/itartificer.com/public_html/sms-erp/resources/views/attendance/teachers/index.blade.php ENDPATH**/ ?>