<?php $__env->startSection('title', 'Yearly Planner'); ?>
<?php $__env->startSection('page_title', 'Yearly Planner'); ?>
<?php $__env->startSection('breadcrumbs'); ?>
    <li class="breadcrumb-item"><a href="<?php echo e(route('dashboard')); ?>">Home</a></li>
    <li class="breadcrumb-item active">Yearly Planner</li>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('page_actions'); ?>
    <?php $planExp = request()->except('export'); ?>
    <a href="<?php echo e(route('yearly-plans.index', array_merge($planExp, ['export' => 'pdf']))); ?>" class="btn btn-light border"><i class="bi bi-file-earmark-pdf text-danger me-1"></i>PDF</a>
    <a href="<?php echo e(route('yearly-plans.index', array_merge($planExp, ['export' => 'word']))); ?>" class="btn btn-light border"><i class="bi bi-file-earmark-word text-primary me-1"></i>Word</a>
    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('academics.create')): ?>
        <a href="<?php echo e(route('yearly-plans.create')); ?>" class="btn btn-primary"><i class="bi bi-plus-lg me-1"></i>New Plan</a>
    <?php endif; ?>
<?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 mb-1">Class</label>
                <select name="class_id" id="yp_f_class" class="form-select form-select-sm">
                    <option value="">All Classes</option>
                    <?php $__currentLoopData = $classes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $class): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($class->id); ?>" <?php if(($filters['class_id'] ?? '') == $class->id): echo 'selected'; endif; ?>><?php echo e($class->name); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
            </div>
            <div class="col-md-3">
                <label class="form-label small mb-1">Section</label>
                <select name="section_id" id="yp_f_section" class="form-select form-select-sm">
                    <option value="">All Sections</option>
                </select>
            </div>
            <div class="col-md-3">
                <label class="form-label small mb-1">Subject</label>
                <select name="subject_id" class="form-select form-select-sm">
                    <option value="">All Subjects</option>
                    <?php $__currentLoopData = $subjects; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $subject): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($subject->id); ?>" <?php if(($filters['subject_id'] ?? '') == $subject->id): echo 'selected'; endif; ?>><?php echo e($subject->name); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
            </div>
            <div class="col-md-3 d-flex gap-2">
                <button class="btn btn-sm btn-primary"><i class="bi bi-funnel me-1"></i>Filter</button>
                <a href="<?php echo e(route('yearly-plans.index')); ?>" class="btn btn-sm btn-light border">Reset</a>
            </div>
        </form>
        <?php $__env->startPush('scripts'); ?>
        <script>
            const YPF_SECTIONS = <?php echo json_encode($sections, 15, 512) ?>;
            const ypfSelected = <?php echo json_encode($filters['section_id'] ?? '', 15, 512) ?>;
            function ypfLoad() {
                const classId = document.getElementById('yp_f_class').value;
                const sel = document.getElementById('yp_f_section');
                sel.innerHTML = '<option value="">All Sections</option>';
                YPF_SECTIONS.filter(s => !classId || String(s.class_id) === String(classId)).forEach(s => {
                    const o = document.createElement('option');
                    o.value = s.id; o.textContent = s.name;
                    if (String(s.id) === String(ypfSelected)) o.selected = true;
                    sel.appendChild(o);
                });
            }
            document.getElementById('yp_f_class').addEventListener('change', ypfLoad);
            ypfLoad();
        </script>
        <?php $__env->stopPush(); ?>
    </div></div>

    <?php if($plans->isEmpty()): ?>
        <div class="card"><div class="card-body text-center text-muted py-5">
            <i class="bi bi-calendar3 fs-1 d-block mb-2"></i>No yearly plans yet.
            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('academics.create')): ?><div class="mt-2"><a href="<?php echo e(route('yearly-plans.create')); ?>" class="btn btn-sm btn-primary">Create the first plan</a></div><?php endif; ?>
        </div></div>
    <?php else: ?>
        <div class="row g-3">
            <?php $__currentLoopData = $plans; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $plan): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <div class="col-md-6 col-xl-4">
                    <div class="card h-100">
                        <?php if($plan->image_url): ?>
                            <a href="<?php echo e(route('yearly-plans.show', $plan)); ?>"><img src="<?php echo e($plan->image_url); ?>" class="card-img-top" style="height:160px;object-fit:cover"></a>
                        <?php else: ?>
                            <div class="bg-light d-flex align-items-center justify-content-center" style="height:160px"><i class="bi bi-image text-muted fs-1"></i></div>
                        <?php endif; ?>
                        <div class="card-body">
                            <h6 class="mb-1"><a href="<?php echo e(route('yearly-plans.show', $plan)); ?>" class="text-decoration-none"><?php echo e($plan->title); ?></a></h6>
                            <div class="small text-muted mb-2">
                                <span class="badge bg-soft-primary"><?php echo e($plan->schoolClass?->name); ?><?php echo e($plan->section ? ' / '.$plan->section->name : ''); ?></span>
                                <span class="badge bg-soft-secondary"><?php echo e($plan->subject?->name); ?></span>
                                <?php if($plan->period): ?><span class="badge bg-soft-info"><?php echo e($plan->period); ?></span><?php endif; ?>
                            </div>
                            <p class="small text-muted mb-0"><?php echo e(\Illuminate\Support\Str::limit($plan->description, 90)); ?></p>
                        </div>
                        <div class="card-footer bg-white d-flex gap-2">
                            <a href="<?php echo e(route('yearly-plans.show', $plan)); ?>" class="btn btn-sm btn-light border">View</a>
                            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('academics.update')): ?><a href="<?php echo e(route('yearly-plans.edit', $plan)); ?>" class="btn btn-sm btn-light border"><i class="bi bi-pencil"></i></a><?php endif; ?>
                            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('academics.delete')): ?>
                                <form method="POST" action="<?php echo e(route('yearly-plans.destroy', $plan)); ?>" class="ms-auto" data-confirm="Delete this plan?">
                                    <?php echo csrf_field(); ?> <?php echo method_field('DELETE'); ?><button class="btn btn-sm btn-light border text-danger"><i class="bi bi-trash"></i></button>
                                </form>
                            <?php endif; ?>
                        </div>
                    </div>
                </div>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </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/yearly-plans/index.blade.php ENDPATH**/ ?>