<?php $__env->startSection('title', 'ফলাফল দেখুন'); ?>

<?php $__env->startSection('content'); ?>
<div class="container-fluid">
    <!-- Search Section - NESCO Style -->
    <div class="row">
        <div class="col-12">
            <div class="card text-center card-primary card-outline">
                <div class="card-header bg-primary text-white">
                    <h5 class="mb-0"><i class="fa fa-search"></i> ফলাফল অনুসন্ধান</h5>
                </div>
                <div class="card-body" style="background-color: #f0f9ff;">
                    <form class="form-horizontal" method="POST" action="<?php echo e(route('results.search')); ?>">
                        <?php echo csrf_field(); ?>
                        <div class="form-group row justify-content-center">
                            <div class="col-md-3">
                                <label class="font-weight-bold">ছাত্র আইডি</label>
                                <input type="text" 
                                       class="form-control form-control-lg text-center <?php $__errorArgs = ['student_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" 
                                       name="student_id" 
                                       placeholder="যেমন: 2026001"
                                       value="<?php echo e(old('student_id')); ?>"
                                       required>
                            </div>
                            
                            <div class="col-md-3">
                                <label class="font-weight-bold">পরীক্ষার ধরন</label>
                                <select name="exam_type" class="form-control form-control-lg" required>
                                    <option value="">নির্বাচন করুন</option>
                                    <?php $__currentLoopData = $examTypes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $type): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($key); ?>"><?php echo e($type); ?></option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                            </div>
                            
                            <div class="col-md-2">
                                <label class="font-weight-bold">বছর</label>
                                <select name="exam_year" class="form-control form-control-lg" required>
                                    <?php $__currentLoopData = range(date('Y'), date('Y')-5); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $year): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($year); ?>"><?php echo e($year); ?></option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                            </div>
                        </div>
                        
                        <div class="form-group row justify-content-center mt-3">
                            <div class="col-md-8">
                                <button type="submit" class="btn btn-info btn-lg">
                                    <i class="fa fa-search"></i> ফলাফল দেখুন
                                </button>
                                <button type="button" id="reset_button" class="btn btn-secondary btn-lg">
                                    <i class="fa fa-undo"></i> রিসেট
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>

    <!-- Quick Actions -->
    <div class="row mt-4">
        <div class="col-md-6">
            <div class="card card-success">
                <div class="card-header">
                    <h5 class="mb-0"><i class="fa fa-pen"></i> ফলাফল录入</h5>
                </div>
                <div class="card-body">
                    <form action="<?php echo e(route('results.class-entry-form')); ?>" method="GET">
                        <?php echo csrf_field(); ?>
                        <div class="form-group">
                            <label>শ্রেণি</label>
                            <select name="class_id" class="form-control" required>
                                <option value="">শ্রেণি নির্বাচন করুন</option>
                                <?php $__currentLoopData = $classes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $class): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($class->id); ?>">
                                    <?php echo e($class->class_name_bn); ?> <?php if($class->section): ?>(<?php echo e($class->section); ?>)<?php endif; ?>
                                </option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </select>
                        </div>
                        
                        <div class="form-group">
                            <label>পরীক্ষার ধরন</label>
                            <select name="exam_type" class="form-control" required>
                                <?php $__currentLoopData = $examTypes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $type): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($key); ?>"><?php echo e($type); ?></option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </select>
                        </div>
                        
                        <div class="form-group">
                            <label>বছর</label>
                            <select name="exam_year" class="form-control" required>
                                <?php $__currentLoopData = range(date('Y'), date('Y')-5); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $year): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($year); ?>"><?php echo e($year); ?></option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </select>
                        </div>
                        
                        <button type="submit" class="btn btn-success btn-block">
                            <i class="fa fa-arrow-right"></i> ফলাফল录入 করুন
                        </button>
                    </form>
                </div>
            </div>
        </div>

        <div class="col-md-6">
            <div class="card card-info">
                <div class="card-header">
                    <h5 class="mb-0"><i class="fa fa-chart-bar"></i> রিপোর্ট ও বিশ্লেষণ</h5>
                </div>
                <div class="card-body">
                    <div class="list-group">
                        <a href="<?php echo e(route('results.tabulation-form')); ?>" class="list-group-item list-group-item-action">
                            <i class="fa fa-table text-info"></i> ট্যাবুলেশন শিট
                        </a>
                        <a href="<?php echo e(route('results.analytics-form')); ?>" class="list-group-item list-group-item-action">
                            <i class="fa fa-chart-pie text-success"></i> ফলাফল বিশ্লেষণ
                        </a>
                        <a href="#" class="list-group-item list-group-item-action">
                            <i class="fa fa-download text-primary"></i> সকল ফলাফল ডাউনলোড
                        </a>
                        <a href="#" class="list-group-item list-group-item-action">
                            <i class="fa fa-print text-warning"></i> মার্কশিট প্রিন্ট (বাল্ক)
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Latest Results -->
    <?php
        $latestMarksheets = App\Models\Marksheet::with('student', 'class')
                            ->latest()
                            ->limit(10)
                            ->get();
    ?>

    <?php if($latestMarksheets->count() > 0): ?>
    <div class="row mt-4">
        <div class="col-12">
            <div class="card">
                <div class="card-header bg-secondary text-white">
                    <h5 class="mb-0"><i class="fa fa-clock"></i> সর্বশেষ প্রকাশিত ফলাফল</h5>
                </div>
                <div class="card-body">
                    <div class="table-responsive">
                        <table class="table table-bordered table-striped">
                            <thead>
                                <tr>
                                    <th>ছাত্র আইডি</th>
                                    <th>নাম</th>
                                    <th>শ্রেণি</th>
                                    <th>পরীক্ষা</th>
                                    <th>GPA</th>
                                    <th>গ্রেড</th>
                                    <th>মেরিট</th>
                                    <th>তারিখ</th>
                                    <th>মার্কশিট</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php $__currentLoopData = $latestMarksheets; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $ms): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <tr>
                                    <td><?php echo e($ms->student->student_id); ?></td>
                                    <td><?php echo e($ms->student->name_bn); ?></td>
                                    <td><?php echo e($ms->class->class_name_bn); ?></td>
                                    <td><?php echo e($ms->exam_name); ?></td>
                                    <td class="font-weight-bold"><?php echo e(number_format($ms->gpa, 2)); ?></td>
                                    <td>
                                        <span class="badge badge-<?php echo e($ms->grade == 'A+' ? 'success' : ($ms->grade == 'F' ? 'danger' : 'info')); ?>">
                                            <?php echo e($ms->grade); ?>

                                        </span>
                                    </td>
                                    <td><?php echo e($ms->rank); ?>/<?php echo e($ms->total_students); ?></td>
                                    <td><?php echo e($ms->published_date->format('d-m-Y')); ?></td>
                                    <td>
                                        <a href="<?php echo e(route('results.download-marksheet', [$ms->student_id, $ms->exam_type, $ms->exam_year])); ?>" 
                                           class="btn btn-sm btn-info" target="_blank">
                                            <i class="fa fa-download"></i>
                                        </a>
                                    </td>
                                </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <?php endif; ?>
</div>

<?php $__env->startSection('scripts'); ?>
<script>
    $(document).ready(function() {
        $('#reset_button').click(function() {
            $('input[name="student_id"]').val('');
            $('select[name="exam_type"]').val('');
            $('select[name="exam_year"]').val('');
        });
    });
</script>
<?php $__env->stopSection(); ?>
<?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/results/index.blade.php ENDPATH**/ ?>