<?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" dir="rtl">
    <div class="col-12">
        <div class="card shadow-sm border-0 rounded-4">
            <div class="card-header bg-info text-white py-3 px-4 rounded-top-4">
                <h5 class="card-title mb-0 urdu-regular fs-4">
                    <i class="bi bi-people-fill ms-2"></i> رہائشی / غیر رہائشی طلباء کی فہرست
                </h5>
            </div>
            <div class="card-body p-4">
                <form id="nonLocalStdForm">
                    <div class="row g-4 align-items-end">

                        <!-- Darja -->
                        <div class="col-md-3">
                            <label for="nls_darja" class="form-label urdu-regular fs-5">درجہ منتخب کریں</label>
                            <?php
                            $css = 'form-select urdu-regular fs-5 shadow-sm border-light-subtle';
                            $crud->darjaatCmb('nls_darja', 'required', $css);
                            ?>
                        </div>

                        <!-- Year -->
                        <div class="col-md-3">
                            <label for="nls_year" class="form-label urdu-regular fs-5">داخلہ سال</label>
                            <input type="text" class="form-control shadow-sm border-light-subtle hijri-picker"
                                id="nls_year" name="nls_year" value="<?php echo htmlspecialchars($defaultYear); ?>"
                                readonly required>
                        </div>

                        <!-- Type -->
                        <div class="col-md-3">
                            <label for="nls_type" class="form-label urdu-regular fs-5">نوعیت</label>
                            <select id="nls_type" class="form-select urdu-regular fs-5 shadow-sm border-light-subtle">
                                <option value="0">غیر رہائشی</option>
                                <option value="1">رہائشی</option>
                            </select>
                        </div>

                        <!-- Submit -->
                        <div class="col-md-3">
                            <button type="submit"
                                class="btn btn-info text-white w-100 urdu-regular fs-5 shadow-sm py-2 px-4 rounded-3"
                                id="btnShowNLS">
                                <i class="bi bi-search ms-1"></i> رپورٹ دکھائیں
                            </button>
                        </div>

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

<!-- Report Results -->
<div id="nlsReportContainer" dir="rtl"></div>

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