<?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="/reports/waivers" style="display:flex;gap:10px;flex-wrap:wrap;align-items:end;">
        <div>
            <label class="form-label" style="font-size:12px;">من تاريخ</label>
            <input type="date" name="date_from" value="<?= e($dateFrom) ?>" class="form-input">
        </div>
        <div>
            <label class="form-label" style="font-size:12px;">إلى تاريخ</label>
            <input type="date" name="date_to" value="<?= e($dateTo) ?>" class="form-input">
        </div>
        <button type="submit" class="btn btn-outline">تصفية</button>
        <a href="/reports/waivers" class="btn btn-sm btn-outline" style="color:#6B7280;">مسح</a>
    </form>
</div>

<div class="card">
    <div style="padding:15px;border-bottom:1px solid #E5E7EB;">
        <strong>النتائج:</strong> <?= count($waivers) ?> عملية تنازل مكتملة
    </div>
    <div class="table-responsive">
        <table class="data-table">
            <thead>
                <tr>
                    <th>التاريخ</th>
                    <th>المتنازل</th>
                    <th>رقم العضوية</th>
                    <th>المتنازل إليه</th>
                    <th>نسبة الرسم</th>
                    <th>مبلغ الرسم</th>
                </tr>
            </thead>
            <tbody>
            <?php if (empty($waivers)): ?>
                <tr><td colspan="6" style="text-align:center;padding:30px;color:#6B7280;">لا توجد نتائج</td></tr>
            <?php else: ?>
                <?php foreach ($waivers as $w): ?>
                <tr>
                    <td><?= e($w['updated_at'] ?? '—') ?></td>
                    <td><?= e($w['source_name'] ?? '—') ?></td>
                    <td><?= e($w['membership_number'] ?? '—') ?></td>
                    <td><?= e($w['target_name'] ?? '—') ?></td>
                    <td><?= e($w['waiver_fee_percentage'] ?? '30') ?>%</td>
                    <td><?= isset($w['waiver_fee_amount']) ? money($w['waiver_fee_amount']) : '—' ?></td>
                </tr>
                <?php endforeach; ?>
            <?php endif; ?>
            </tbody>
        </table>
    </div>
</div>

<?php $__template->endSection(); ?>
