<?php $__template->layout('Layout.main'); ?>
<?php $__template->section('title'); ?>التنازلات<?php $__template->endSection(); ?>
<?php $__template->section('page_actions'); ?>
<div style="padding:8px 16px;background:#EFF6FF;border:1px solid #BFDBFE;border-radius:6px;font-size:13px;color:#0284C7;">
    💡 لتقديم طلب تنازل، اذهب لصفحة العضو
</div>
<?php $__template->endSection(); ?>
<?php $__template->section('content'); ?>
<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):
    $wStatusLabel = match($r['status'] ?? '') { 'requested' => 'مقدم', 'approved' => 'معتمد', 'fee_paid' => 'تم الدفع', 'completed' => 'مكتمل', 'rejected' => 'مرفوض', default => $r['status'] ?? '' };
    $wStatusColor = match($r['status'] ?? '') { 'completed' => '#059669', 'approved' => '#0284C7', 'fee_paid' => '#0D7377', 'rejected' => '#DC2626', default => '#D97706' };
?>
<tr>
    <td><?= (int) $r['id'] ?></td>
    <td><a href="/members/<?= (int) $r['source_member_id'] ?>" style="color:#0D7377;font-weight:600;"><?= e($r['source_name'] ?? '') ?></a></td>
    <td><?php if (!empty($r['target_name'])): ?><a href="/members/<?= (int) ($r['target_member_id'] ?? 0) ?>" style="color:#1D4ED8;font-weight:600;"><?= e($r['target_name']) ?></a><?php else: ?>—<?php endif; ?></td>
    <td style="font-weight:600;"><?= e($r['membership_number'] ?? '—') ?></td>
    <td style="font-weight:700;color:#0D7377;"><?= money($r['waiver_fee_amount'] ?? '0') ?></td>
    <td style="font-size:12px;color:#6B7280;"><?= e(substr($r['created_at'] ?? '', 0, 10)) ?></td>
    <td><span style="color:<?= $wStatusColor ?>;font-weight:600;">● <?= $wStatusLabel ?></span></td>
    <td><a href="/waivers/<?= (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(); ?>