<?php
// Default year from session
$defaultYear = date('Y-m-d');
if (isset($_SESSION['hijri'])) {
    $dt = new DateTime($_SESSION['hijri']);
    $defaultYear = $dt->format('Y-m-d');
}
?>

<div class="row mb-4">
    <div class="col-12">
        <div class="card shadow-sm">
            <div class="card-header bg-primary text-white text-end">
                <h5 class="card-title mb-0 urdu-regular">رجسٹر داخل / خارج</h5>
            </div>
            <div class="card-body">
                <form id="admissionRegisterForm" dir="rtl">
                    <div class="row g-3 align-items-end justify-content-end">

                        <!-- Darja -->
                        <div class="col-md-3 text-end">
                            <label for="arl_darja" class="form-label urdu-regular">
                                درجہ منتخب کریں <span class="text-danger">*</span>
                            </label>
                            <?php
                            $css = 'form-select text-end urdu-regular shadow-sm';
                            $crud->darjaatCmb('arl_darja', 'required', $css);
                            ?>
                        </div>

                        <!-- Year (promotion date) -->
                        <div class="col-md-4">
                            <label class="form-label fw-bold urdu-regular fs-5" for="rpt_date_start">تاریخِ
                                داخلہ</label>
                            <div class="input-group input-group-lg shadow-sm rounded-3 overflow-hidden" dir="ltr">
                                <span class="input-group-text bg-light border-0 text-primary"><i
                                        class="bi bi-calendar-event"></i></span>
                                <input type="text" id="rpt_date_start" name="arl_year"
                                    class="form-control border-0 text-end hijri-picker"
                                    value="<?php echo htmlspecialchars($defaultYear); ?>" readonly>
                            </div>
                        </div>

                        <!-- Type: داخل / خارج -->
                        <div class="col-md-3 text-end">
                            <label class="form-label urdu-regular d-block">نوعیت</label>
                            <div class="btn-group w-100" role="group">
                                <input type="radio" class="btn-check" name="arl_type" id="arl_dakhil" value="1" checked>
                                <label class="btn btn-outline-success urdu-regular fs-5" for="arl_dakhil">داخل</label>

                                <input type="radio" class="btn-check" name="arl_type" id="arl_kharij" value="0">
                                <label class="btn btn-outline-danger urdu-regular fs-5" for="arl_kharij">خارج</label>
                            </div>
                        </div>

                        <!-- Submit -->
                        <div class="col-md-3 text-end mt-3 mt-md-2">
                            <button type="submit" class="btn btn-success w-100 urdu-regular shadow-sm" id="btnShowARL">
                                رپورٹ دکھائیں
                            </button>
                        </div>

                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<!-- Report Container -->
<div class="row">
    <div class="col-12">
        <div id="arlReportContainer"></div>
    </div>
</div>

<script src="assets/js/admission_register_list.js"></script>