<?php

declare(strict_types=1);

/*
|--------------------------------------------------------------------------
| EXPECTED VARIABLES
|--------------------------------------------------------------------------
|
| $examTypes
| $classes
| $exam_type_id
| $class_id
|
*/

?>

<div class="card card-outline card-primary">

    <div class="card-header">

        <h3 class="card-title">

            Filter Results

        </h3>

    </div>

    <div class="card-body">

        <form method="GET">

            <div class="row">

                <!-- EXAM -->

                <div class="col-md-4 mb-3">

                    <label>

                        Exam Type

                    </label>

                    <select
                        name="exam_type_id"
                        class="form-control select2"
                        required
                    >

                        <option value="">

                            Select Exam

                        </option>

                        <?php foreach ($examTypes as $exam): ?>

                            <option
                                value="<?= (int) $exam['id']; ?>"
                                <?= $exam_type_id === (int) $exam['id']
                                    ? 'selected'
                                    : ''; ?>
                            >

                                <?= htmlspecialchars($exam['exam_name']); ?>

                            </option>

                        <?php endforeach; ?>

                    </select>

                </div>

                <!-- CLASS -->

                <div class="col-md-4 mb-3">

                    <label>

                        Class

                    </label>

                    <select
                        name="class_id"
                        class="form-control select2"
                        required
                    >

                        <option value="">

                            Select Class

                        </option>

                        <?php foreach ($classes as $class): ?>

                            <option
                                value="<?= (int) $class['id']; ?>"
                                <?= $class_id === (int) $class['id']
                                    ? 'selected'
                                    : ''; ?>
                            >

                                <?= htmlspecialchars($class['class_name']); ?>

                            </option>

                        <?php endforeach; ?>

                    </select>

                </div>

                <!-- BUTTON -->

                <div class="col-md-4 mb-3 d-flex align-items-end">

                    <button
                        type="submit"
                        class="btn btn-primary w-100"
                    >

                        <i class="fas fa-search mr-1"></i>

                        Search Results

                    </button>

                </div>

            </div>

        </form>

    </div>

</div>