<?php $__template->layout('Layout.main'); ?>
<?php $__template->section('title'); ?>الأعضاء المؤقتون<?php $__template->endSection(); ?>
<?php $__template->section('content'); ?>

<div class="card" style="margin-bottom:20px;padding:15px;">
    <form method="GET" action="/temporary" style="display:flex;gap:10px;flex-wrap:wrap;align-items:end;">
        <div>
            <label class="form-label" style="font-size:12px;">بحث</label>
            <input type="text" name="q" value="<?= e($filters['q'] ?? '') ?>" placeholder="الاسم، الرقم القومي..." class="form-input" style="min-width:200px;">
        </div>
        <div>
            <label class="form-label" style="font-size:12px;">الفئة</label>
            <select name="category" class="form-select" style="min-width:150px;">
                <option value="">الكل</option>
                <?php foreach ($categories as $code => $label): ?>
                    <option value="<?= e($code) ?>" <?= ($filters['category'] ?? '') === $code ? 'selected' : '' ?>><?= e($label) ?></option>
                <?php endforeach; ?>
            </select>
        </div>
        <div>
            <label class="form-label" style="font-size:12px;">الحالة</label>
            <select name="status" class="form-select">
                <option value="">الكل</option>
                <option value="active" <?= ($filters['status'] ?? '') === 'active' ? 'selected' : '' ?>>نشط</option>
                <option value="inactive" <?= ($filters['status'] ?? '') === 'inactive' ? 'selected' : '' ?>>غير نشط</option>
            </select>
        </div>
        <button type="submit" class="btn btn-outline">بحث</button>
        <a href="/temporary" class="btn btn-sm btn-outline" style="color:#6B7280;">مسح</a>
    </form>
</div>

<div class="card">
    <div class="table-responsive">
        <table class="data-table">
            <thead><tr><th>الاسم</th><th>العضو الأساسي</th><th>الفئة</th><th>النوع</th><th>السن</th><th>الرسوم</th><th>الحالة</th><th>الإجراءات</th></tr></thead>
            <tbody>
                <?php foreach ($rows as $r): ?>
                <tr>
                    <td style="font-weight:600;"><?= e($r['full_name_ar']) ?></td>
                    <td><a href="/members/<?= (int) $r['member_id'] ?>" style="color:#0D7377;"><?= e($r['member_name']) ?></a> <small style="color:#9CA3AF;"><?= e($r['membership_number'] ?? '') ?></small></td>
                    <td style="font-size:13px;"><?php $cats = \App\Modules\Temporary\Models\TemporaryMember::getCategories(); echo e($cats[$r['category']] ?? $r['category']); ?></td>
                    <td><?= $r['gender'] === 'male' ? 'ذكر' : 'أنثى' ?></td>
                    <td><?= (int) ($r['age_years'] ?? 0) ?></td>
                    <td style="font-weight:600;"><?= money($r['addition_fee'] ?? '0') ?></td>
                    <td><span style="color:<?= $r['status'] === 'active' ? '#059669' : '#DC2626' ?>;font-weight:600;">● <?= $r['status'] === 'active' ? 'نشط' : 'غير نشط' ?></span></td>
                    <td><a href="/members/<?= (int) $r['member_id'] ?>/temporary/<?= (int) $r['id'] ?>" class="btn btn-sm btn-outline">عرض</a></td>
                </tr>
                <?php endforeach; ?>
                <?php if (empty($rows)): ?>
                <tr><td colspan="8" style="text-align:center;padding:40px;color:#6B7280;">لا يوجد أعضاء مؤقتون</td></tr>
                <?php endif; ?>
            </tbody>
        </table>
    </div>
</div>
<?php $__template->endSection(); ?>