<ahref="/audit/entity/<?=urlencode($r['entity_type'])?>/<?=(int)$r['entity_id']?>"style="color:#0D7377;font-size:12px;font-weight:600;">عرض كل سجل هذا الكيان ←</a>
<?phpif(empty($rows)):?>
</div>
<tr><tdcolspan="7"style="text-align:center;padding:40px;color:#6B7280;">لا توجد سجلات</td></tr>
"SELECT id FROM `{$depTable}` WHERE member_id = ? AND status = 'pending_payment' AND is_archived = 0",
[$memberId]
);
foreach($pendingDepsas$dep){
// Only activate if no separate pending payment request exists
$hasSeparateRequest=$db->selectOne(
"SELECT id FROM payment_requests WHERE member_id = ? AND payment_type = 'addition_fee' AND related_entity_type = ? AND related_entity_id = ? AND status IN ('pending','processing') AND is_voided = 0 LIMIT 1",