Commit 3af8e795 authored by Fares's avatar Fares

feat(members): unified insurance record showing all procedures

The السجل التأميني page now shows a complete record of ALL procedures
that affected a membership — death cases, waiver transfers, and
transfer/separation requests. Works for both active and archived members.

Shows: procedure details, role (source/target), fees, approval info,
payments related to procedures, death audit timeline, archive snapshots.
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 08335cb4
...@@ -879,16 +879,82 @@ class MemberController extends Controller ...@@ -879,16 +879,82 @@ class MemberController extends Controller
$this->authorize('member.view'); $this->authorize('member.view');
$db = App::getInstance()->db(); $db = App::getInstance()->db();
$member = $db->selectOne("SELECT id, full_name_ar, membership_number, status, is_archived FROM members WHERE id = ?", [(int) $id]); $member = $db->selectOne("SELECT * FROM members WHERE id = ?", [(int) $id]);
if (!$member) return $this->redirect('/members')->withError('العضو غير موجود'); if (!$member) return $this->redirect('/members')->withError('العضو غير موجود');
$cases = \App\Modules\Death\Services\DeathAuditService::getCasesForMember((int) $id); $memberId = (int) $id;
$auditLogs = \App\Modules\Death\Services\DeathAuditService::getForMember((int) $id);
// Death cases (as source or target)
$deathCases = $db->select(
"SELECT dc.*, m.full_name_ar as member_name, m.membership_number as member_number,
tm.full_name_ar as target_member_name
FROM death_cases dc
JOIN members m ON m.id = dc.member_id
LEFT JOIN members tm ON tm.id = dc.transferred_to_member_id
WHERE dc.member_id = ? OR dc.transferred_to_member_id = ?
ORDER BY dc.created_at DESC",
[$memberId, $memberId]
);
// Waiver requests (as source or target)
$waiverRequests = $db->select(
"SELECT wr.*, sm.full_name_ar as source_member_name, sm.membership_number as source_number,
tm.full_name_ar as target_member_name, tm.membership_number as target_number,
e.full_name_ar as approved_by_name
FROM waiver_requests wr
JOIN members sm ON sm.id = wr.source_member_id
LEFT JOIN members tm ON tm.id = wr.target_member_id
LEFT JOIN employees e ON e.id = wr.approved_by
WHERE wr.source_member_id = ? OR wr.target_member_id = ?
ORDER BY wr.created_at DESC",
[$memberId, $memberId]
);
// Transfer requests (as source or target)
$transferRequests = $db->select(
"SELECT tr.*, sm.full_name_ar as source_member_name, sm.membership_number as source_number,
tm.full_name_ar as target_member_name, tm.membership_number as target_number,
e.full_name_ar as approved_by_name
FROM transfer_requests tr
JOIN members sm ON sm.id = tr.source_member_id
LEFT JOIN members tm ON tm.id = tr.target_member_id
LEFT JOIN employees e ON e.id = tr.approved_by
WHERE tr.source_member_id = ? OR tr.target_member_id = ?
ORDER BY tr.created_at DESC",
[$memberId, $memberId]
);
// Death audit logs (detailed steps)
$deathAuditLogs = \App\Modules\Death\Services\DeathAuditService::getForMember($memberId);
// Payments related to all procedures
$procedurePayments = $db->select(
"SELECT p.*, pr.payment_type as request_type, pr.description_ar as request_description
FROM payments p
LEFT JOIN payment_requests pr ON pr.id = p.payment_request_id
WHERE p.member_id = ? AND p.is_voided = 0
AND (p.payment_type IN ('death_fee','waiver_fee','transfer_fee','separation_fee')
OR pr.payment_type IN ('death_fee','waiver_fee','transfer_fee','separation_fee'))
ORDER BY p.payment_date DESC",
[$memberId]
);
// Archive snapshots for this member
$snapshots = $db->select(
"SELECT id, snapshot_reason, membership_number, snapshot_taken_at, created_by
FROM archive_snapshots WHERE entity_type = 'members' AND entity_id = ?
ORDER BY snapshot_taken_at DESC",
[$memberId]
);
return $this->view('Members.Views.insurance-record', [ return $this->view('Members.Views.insurance-record', [
'member' => (object) $member, 'member' => (object) $member,
'cases' => $cases, 'deathCases' => $deathCases,
'auditLogs' => $auditLogs, 'waiverRequests' => $waiverRequests,
'transferRequests' => $transferRequests,
'deathAuditLogs' => $deathAuditLogs,
'procedurePayments' => $procedurePayments,
'snapshots' => $snapshots,
]); ]);
} }
} }
\ No newline at end of file
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<?php $__template->endSection(); ?> <?php $__template->endSection(); ?>
<?php $__template->section('content'); ?> <?php $__template->section('content'); ?>
<div style="max-width:900px;"> <div style="max-width:1000px;">
<!-- Header --> <!-- Header -->
<div class="card" style="padding:20px;margin-bottom:20px;background:linear-gradient(135deg, #EFF6FF, #DBEAFE);border:1px solid #93C5FD;"> <div class="card" style="padding:20px;margin-bottom:20px;background:linear-gradient(135deg, #EFF6FF, #DBEAFE);border:1px solid #93C5FD;">
...@@ -15,106 +15,269 @@ ...@@ -15,106 +15,269 @@
<div> <div>
<h2 style="margin:0 0 5px;color:#1E40AF;">السجل التأميني</h2> <h2 style="margin:0 0 5px;color:#1E40AF;">السجل التأميني</h2>
<p style="margin:0;color:#6B7280;font-size:14px;"><?= e($member->full_name_ar) ?> — رقم العضوية: <?= e($member->membership_number ?? 'مؤرشف') ?></p> <p style="margin:0;color:#6B7280;font-size:14px;"><?= e($member->full_name_ar) ?> — رقم العضوية: <?= e($member->membership_number ?? 'مؤرشف') ?></p>
<?php if ($member->is_archived): ?>
<span style="display:inline-block;margin-top:5px;background:#FEE2E2;color:#991B1B;padding:2px 8px;border-radius:4px;font-size:12px;font-weight:600;">عضوية مؤرشفة (<?= e($member->status) ?>)</span>
<?php endif; ?>
</div> </div>
<div style="font-size:48px;">&#x1f4cb;</div> <div style="font-size:48px;">&#x1f4cb;</div>
</div> </div>
</div> </div>
<!-- Death Cases Summary --> <?php
<?php if (!empty($cases)): ?> $hasAny = !empty($deathCases) || !empty($waiverRequests) || !empty($transferRequests);
if (!$hasAny):
?>
<div class="card" style="padding:40px;text-align:center;">
<div style="font-size:48px;margin-bottom:10px;">&#x1f4cb;</div>
<p style="color:#6B7280;">لا يوجد سجل تأميني لهذا العضو</p>
</div>
<?php else: ?>
<!-- ═══════ DEATH CASES ═══════ -->
<?php if (!empty($deathCases)): ?>
<div class="card" style="margin-bottom:20px;"> <div class="card" style="margin-bottom:20px;">
<div style="padding:15px 20px;border-bottom:1px solid #E5E7EB;"> <div style="padding:15px 20px;border-bottom:1px solid #E5E7EB;background:#F9FAFB;">
<h3 style="margin:0;font-size:16px;color:#1F2937;">حالات الوفاة المرتبطة</h3> <h3 style="margin:0;font-size:16px;color:#1F2937;">&#x1f54a; حالات الوفاة (<?= count($deathCases) ?>)</h3>
</div> </div>
<div class="table-responsive"> <div style="padding:15px 20px;">
<table class="data-table" style="width:100%;"> <?php foreach ($deathCases as $dc):
$dcTypeLabel = match($dc['deceased_type']) {
'primary_member' => 'عضو أساسي', 'spouse' => 'زوج/ة', 'child' => 'ابن/ابنة', default => $dc['deceased_type'],
};
$dcStatusLabel = match($dc['status']) {
'recorded' => 'مسجل', 'board_review' => 'مراجعة مجلس الإدارة', 'board_approved' => 'معتمد',
'rejected' => 'مرفوض', 'fee_paid' => 'تم السداد', 'pending_form_fill' => 'انتظار ملء الاستمارة',
'completed' => 'مكتمل', default => $dc['status'],
};
$dcStatusColor = match($dc['status']) {
'completed' => '#059669', 'rejected' => '#DC2626', 'board_approved','fee_paid' => '#3B82F6', default => '#F59E0B',
};
$isSource = ((int) $dc['member_id'] === (int) $member->id);
?>
<div style="border:1px solid #E5E7EB;border-radius:8px;padding:15px;margin-bottom:12px;<?= $dc['status'] === 'completed' ? 'border-right:4px solid #059669;' : '' ?>">
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:8px;">
<div>
<span style="font-weight:700;">حالة وفاة #<?= (int) $dc['id'] ?></span>
<span style="margin:0 8px;color:#9CA3AF;">|</span>
<span style="font-size:13px;color:#6B7280;"><?= $dcTypeLabel ?></span>
<span style="margin:0 8px;color:#9CA3AF;">|</span>
<span style="font-size:13px;background:<?= $isSource ? '#FEE2E2' : '#DCFCE7' ?>;color:<?= $isSource ? '#991B1B' : '#166534' ?>;padding:1px 6px;border-radius:3px;"><?= $isSource ? 'العضو المتوفى' : 'المستفيد (العضوية الجديدة)' ?></span>
</div>
<span style="color:<?= $dcStatusColor ?>;font-weight:600;font-size:13px;"><?= $dcStatusLabel ?></span>
</div>
<table style="width:100%;font-size:13px;">
<tr><td style="padding:3px 0;color:#6B7280;width:25%;">العضو المتوفى</td><td style="padding:3px 0;font-weight:600;"><?= e($dc['member_name']) ?></td></tr>
<tr><td style="padding:3px 0;color:#6B7280;">تاريخ الوفاة</td><td style="padding:3px 0;"><?= e($dc['death_date'] ?? '—') ?></td></tr>
<?php if (!empty($dc['target_member_name'])): ?>
<tr><td style="padding:3px 0;color:#6B7280;">المستفيد (العضوية الجديدة)</td><td style="padding:3px 0;"><?= e($dc['target_member_name']) ?></td></tr>
<?php endif; ?>
<?php if (!empty($dc['fee_amount']) && bccomp($dc['fee_amount'], '0', 2) > 0): ?>
<tr><td style="padding:3px 0;color:#6B7280;">إجمالي الرسوم</td><td style="padding:3px 0;font-weight:700;color:#059669;"><?= money($dc['fee_amount']) ?></td></tr>
<?php endif; ?>
<?php if (!empty($dc['board_fee_amount']) && bccomp($dc['board_fee_amount'], '0', 2) > 0): ?>
<tr><td style="padding:3px 0;color:#6B7280;">رسوم مجلس الأمناء</td><td style="padding:3px 0;"><?= money($dc['board_fee_amount']) ?> (<?= e($dc['board_fee_method'] === 'percentage' ? $dc['board_fee_value'] . '%' : 'مبلغ ثابت') ?>)</td></tr>
<?php endif; ?>
<tr><td style="padding:3px 0;color:#6B7280;">تاريخ التسجيل</td><td style="padding:3px 0;"><?= e(substr($dc['created_at'], 0, 16)) ?></td></tr>
<?php if ($dc['status'] === 'completed' && !empty($dc['updated_at'])): ?>
<tr><td style="padding:3px 0;color:#6B7280;">تاريخ الإتمام</td><td style="padding:3px 0;"><?= e(substr($dc['updated_at'], 0, 16)) ?></td></tr>
<?php endif; ?>
</table>
<div style="margin-top:8px;"><a href="/death/<?= (int) $dc['id'] ?>" class="btn btn-sm btn-outline" style="font-size:11px;">عرض التفاصيل</a></div>
</div>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
<!-- ═══════ WAIVER REQUESTS ═══════ -->
<?php if (!empty($waiverRequests)): ?>
<div class="card" style="margin-bottom:20px;">
<div style="padding:15px 20px;border-bottom:1px solid #E5E7EB;background:#F9FAFB;">
<h3 style="margin:0;font-size:16px;color:#1F2937;">&#x1f4dd; طلبات التنازل (<?= count($waiverRequests) ?>)</h3>
</div>
<div style="padding:15px 20px;">
<?php foreach ($waiverRequests as $wr):
$wrStatusLabel = match($wr['status']) {
'requested' => 'مقدم', 'approved' => 'معتمد', 'fee_paid' => 'تم السداد',
'completed' => 'مكتمل', 'rejected' => 'مرفوض', 'cancelled' => 'ملغى', default => $wr['status'],
};
$wrStatusColor = match($wr['status']) {
'completed' => '#059669', 'rejected','cancelled' => '#DC2626', 'approved','fee_paid' => '#3B82F6', default => '#F59E0B',
};
$isSource = ((int) $wr['source_member_id'] === (int) $member->id);
?>
<div style="border:1px solid #E5E7EB;border-radius:8px;padding:15px;margin-bottom:12px;<?= $wr['status'] === 'completed' ? 'border-right:4px solid #059669;' : '' ?>">
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:8px;">
<div>
<span style="font-weight:700;">طلب تنازل #<?= (int) $wr['id'] ?></span>
<span style="margin:0 8px;color:#9CA3AF;">|</span>
<span style="font-size:13px;background:<?= $isSource ? '#FEE2E2' : '#DCFCE7' ?>;color:<?= $isSource ? '#991B1B' : '#166534' ?>;padding:1px 6px;border-radius:3px;"><?= $isSource ? 'المتنازل (العضوية المؤرشفة)' : 'المتنازل إليه (المستفيد)' ?></span>
</div>
<span style="color:<?= $wrStatusColor ?>;font-weight:600;font-size:13px;"><?= $wrStatusLabel ?></span>
</div>
<table style="width:100%;font-size:13px;">
<tr><td style="padding:3px 0;color:#6B7280;width:25%;">المتنازل</td><td style="padding:3px 0;font-weight:600;"><?= e($wr['source_member_name']) ?></td></tr>
<tr><td style="padding:3px 0;color:#6B7280;">المتنازل إليه</td><td style="padding:3px 0;font-weight:600;"><?= e($wr['target_member_name'] ?? '—') ?></td></tr>
<tr><td style="padding:3px 0;color:#6B7280;">رقم العضوية</td><td style="padding:3px 0;font-family:monospace;font-weight:700;"><?= e($wr['membership_number']) ?></td></tr>
<tr><td style="padding:3px 0;color:#6B7280;">قيمة العضوية وقت التنازل</td><td style="padding:3px 0;"><?= money($wr['membership_value_at_waiver']) ?></td></tr>
<tr><td style="padding:3px 0;color:#6B7280;">نسبة رسوم التنازل</td><td style="padding:3px 0;"><?= e($wr['waiver_fee_percentage']) ?>%</td></tr>
<tr><td style="padding:3px 0;color:#6B7280;">رسوم التنازل</td><td style="padding:3px 0;font-weight:700;color:#059669;"><?= money($wr['waiver_fee_amount']) ?></td></tr>
<tr><td style="padding:3px 0;color:#6B7280;">عدد التابعين الأصلي</td><td style="padding:3px 0;"><?= (int) $wr['original_dependent_count'] ?></td></tr>
<?php if ($wr['new_dependent_count'] !== null): ?>
<tr><td style="padding:3px 0;color:#6B7280;">عدد التابعين الجديد</td><td style="padding:3px 0;"><?= (int) $wr['new_dependent_count'] ?></td></tr>
<?php endif; ?>
<?php if (!empty($wr['approved_by_name'])): ?>
<tr><td style="padding:3px 0;color:#6B7280;">معتمد بواسطة</td><td style="padding:3px 0;"><?= e($wr['approved_by_name']) ?> (<?= e(substr($wr['approved_at'] ?? '', 0, 16)) ?>)</td></tr>
<?php endif; ?>
<tr><td style="padding:3px 0;color:#6B7280;">تاريخ الطلب</td><td style="padding:3px 0;"><?= e(substr($wr['created_at'], 0, 16)) ?></td></tr>
<?php if ($wr['status'] === 'completed' && !empty($wr['updated_at'])): ?>
<tr><td style="padding:3px 0;color:#6B7280;">تاريخ الإتمام</td><td style="padding:3px 0;"><?= e(substr($wr['updated_at'], 0, 16)) ?></td></tr>
<?php endif; ?>
</table>
<div style="margin-top:8px;"><a href="/waivers/<?= (int) $wr['id'] ?>" class="btn btn-sm btn-outline" style="font-size:11px;">عرض التفاصيل</a></div>
</div>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
<!-- ═══════ TRANSFER REQUESTS ═══════ -->
<?php if (!empty($transferRequests)): ?>
<div class="card" style="margin-bottom:20px;">
<div style="padding:15px 20px;border-bottom:1px solid #E5E7EB;background:#F9FAFB;">
<h3 style="margin:0;font-size:16px;color:#1F2937;">&#x1f504; طلبات النقل والفصل (<?= count($transferRequests) ?>)</h3>
</div>
<div style="padding:15px 20px;">
<?php foreach ($transferRequests as $tr):
$trTypeLabel = match($tr['transfer_type'] ?? '') {
'full_transfer' => 'نقل كامل', 'child_separation' => 'فصل أبناء', 'child_mandatory_25' => 'فصل إلزامي (25 سنة)',
'sports_conversion' => 'تحويل رياضي', 'cross_branch' => 'نقل بين الفروع', default => $tr['transfer_type'] ?? '—',
};
$trStatusLabel = match($tr['status']) {
'requested' => 'مقدم', 'approved' => 'معتمد', 'fee_paid' => 'تم السداد',
'completed' => 'مكتمل', 'rejected' => 'مرفوض', 'cancelled' => 'ملغى', default => $tr['status'],
};
$trStatusColor = match($tr['status']) {
'completed' => '#059669', 'rejected','cancelled' => '#DC2626', 'approved','fee_paid' => '#3B82F6', default => '#F59E0B',
};
$isSource = ((int) $tr['source_member_id'] === (int) $member->id);
?>
<div style="border:1px solid #E5E7EB;border-radius:8px;padding:15px;margin-bottom:12px;<?= $tr['status'] === 'completed' ? 'border-right:4px solid #059669;' : '' ?>">
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:8px;">
<div>
<span style="font-weight:700;">طلب نقل #<?= (int) $tr['id'] ?></span>
<span style="margin:0 8px;color:#9CA3AF;">|</span>
<span style="font-size:13px;color:#6B7280;"><?= $trTypeLabel ?></span>
<span style="margin:0 8px;color:#9CA3AF;">|</span>
<span style="font-size:13px;background:<?= $isSource ? '#FEE2E2' : '#DCFCE7' ?>;color:<?= $isSource ? '#991B1B' : '#166534' ?>;padding:1px 6px;border-radius:3px;"><?= $isSource ? 'العضوية الأصلية' : 'العضوية الجديدة' ?></span>
</div>
<span style="color:<?= $trStatusColor ?>;font-weight:600;font-size:13px;"><?= $trStatusLabel ?></span>
</div>
<table style="width:100%;font-size:13px;">
<tr><td style="padding:3px 0;color:#6B7280;width:25%;">العضو الأصلي</td><td style="padding:3px 0;font-weight:600;"><?= e($tr['source_member_name']) ?></td></tr>
<?php if (!empty($tr['target_member_name'])): ?>
<tr><td style="padding:3px 0;color:#6B7280;">العضو الجديد</td><td style="padding:3px 0;font-weight:600;"><?= e($tr['target_member_name']) ?></td></tr>
<?php endif; ?>
<?php if (!empty($tr['source_membership_number'])): ?>
<tr><td style="padding:3px 0;color:#6B7280;">رقم العضوية الأصلي</td><td style="padding:3px 0;font-family:monospace;"><?= e($tr['source_membership_number']) ?></td></tr>
<?php endif; ?>
<?php if (!empty($tr['new_membership_number'])): ?>
<tr><td style="padding:3px 0;color:#6B7280;">رقم العضوية الجديد</td><td style="padding:3px 0;font-family:monospace;font-weight:700;"><?= e($tr['new_membership_number']) ?></td></tr>
<?php endif; ?>
<?php if (!empty($tr['total_fee']) && bccomp($tr['total_fee'], '0', 2) > 0): ?>
<tr><td style="padding:3px 0;color:#6B7280;">إجمالي الرسوم</td><td style="padding:3px 0;font-weight:700;color:#059669;"><?= money($tr['total_fee']) ?></td></tr>
<?php endif; ?>
<?php if (!empty($tr['separation_fee']) && bccomp($tr['separation_fee'], '0', 2) > 0): ?>
<tr><td style="padding:3px 0;color:#6B7280;">رسوم الفصل</td><td style="padding:3px 0;"><?= money($tr['separation_fee']) ?></td></tr>
<?php endif; ?>
<?php if (!empty($tr['approved_by_name'])): ?>
<tr><td style="padding:3px 0;color:#6B7280;">معتمد بواسطة</td><td style="padding:3px 0;"><?= e($tr['approved_by_name']) ?> (<?= e(substr($tr['approved_at'] ?? '', 0, 16)) ?>)</td></tr>
<?php endif; ?>
<tr><td style="padding:3px 0;color:#6B7280;">تاريخ الطلب</td><td style="padding:3px 0;"><?= e(substr($tr['created_at'], 0, 16)) ?></td></tr>
<?php if (!empty($tr['completed_at'])): ?>
<tr><td style="padding:3px 0;color:#6B7280;">تاريخ الإتمام</td><td style="padding:3px 0;"><?= e(substr($tr['completed_at'], 0, 16)) ?></td></tr>
<?php endif; ?>
</table>
<div style="margin-top:8px;"><a href="/transfers/<?= (int) $tr['id'] ?>" class="btn btn-sm btn-outline" style="font-size:11px;">عرض التفاصيل</a></div>
</div>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
<!-- ═══════ PROCEDURE PAYMENTS ═══════ -->
<?php if (!empty($procedurePayments)): ?>
<div class="card" style="margin-bottom:20px;">
<div style="padding:15px 20px;border-bottom:1px solid #E5E7EB;background:#F9FAFB;">
<h3 style="margin:0;font-size:16px;color:#1F2937;">&#x1f4b0; المدفوعات المرتبطة بالإجراءات (<?= count($procedurePayments) ?>)</h3>
</div>
<div class="table-responsive" style="padding:10px;">
<table class="data-table" style="width:100%;font-size:13px;">
<thead> <thead>
<tr> <tr>
<th>#</th> <th>رقم الإيصال</th>
<th>العضو المتوفى</th> <th>النوع</th>
<th>نوع الوفاة</th> <th>الوصف</th>
<th>تاريخ الوفاة</th> <th>المبلغ</th>
<th>الحالة</th> <th>تاريخ الدفع</th>
<th></th> <th>طريقة الدفع</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php foreach ($cases as $c): <?php foreach ($procedurePayments as $pp):
$typeLabel = match($c['deceased_type']) { $ppTypeLabel = match($pp['payment_type'] ?? $pp['request_type'] ?? '') {
'primary_member' => 'عضو أساسي', 'death_fee' => 'رسوم وفاة', 'waiver_fee' => 'رسوم تنازل',
'spouse' => 'زوج/ة', 'transfer_fee' => 'رسوم نقل', 'separation_fee' => 'رسوم فصل', default => $pp['payment_type'] ?? '—',
'child' => 'ابن/ابنة', };
default => $c['deceased_type'], $ppMethodLabel = match($pp['payment_method'] ?? '') {
}; 'cash' => 'نقدي', 'card' => 'بطاقة', 'transfer' => 'تحويل', 'cheque' => 'شيك', default => $pp['payment_method'] ?? '—',
$statusLabel = match($c['status']) { };
'recorded' => 'مسجل', ?>
'board_review' => 'مراجعة مجلس الإدارة',
'board_approved' => 'معتمد',
'rejected' => 'مرفوض',
'fee_paid' => 'تم السداد',
'pending_form_fill' => 'انتظار ملء الاستمارة',
'completed' => 'مكتمل',
default => $c['status'],
};
$statusColor = match($c['status']) {
'completed' => '#059669',
'rejected' => '#DC2626',
'board_approved', 'fee_paid' => '#3B82F6',
default => '#F59E0B',
};
?>
<tr> <tr>
<td style="font-weight:600;">#<?= (int) $c['id'] ?></td> <td style="font-weight:600;font-family:monospace;"><?= e($pp['receipt_number'] ?? '#' . $pp['id']) ?></td>
<td><?= e($c['member_name']) ?></td> <td><span style="background:#EFF6FF;color:#1E40AF;padding:2px 6px;border-radius:3px;font-size:11px;"><?= $ppTypeLabel ?></span></td>
<td><?= $typeLabel ?></td> <td style="font-size:12px;"><?= e($pp['request_description'] ?? $pp['description'] ?? '—') ?></td>
<td><?= e($c['death_date'] ?? '') ?></td> <td style="font-weight:700;color:#059669;"><?= money($pp['amount']) ?></td>
<td><span style="color:<?= $statusColor ?>;font-weight:600;"><?= $statusLabel ?></span></td> <td><?= e(substr($pp['payment_date'] ?? $pp['created_at'] ?? '', 0, 16)) ?></td>
<td><a href="/death/<?= (int) $c['id'] ?>" class="btn btn-sm btn-outline">عرض</a></td> <td><?= $ppMethodLabel ?></td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
</tbody> </tbody>
</table> </table>
</div> </div>
</div> </div>
<?php endif; ?> <?php endif; ?>
<!-- Audit Timeline --> <!-- ═══════ DEATH AUDIT TIMELINE ═══════ -->
<?php if (!empty($auditLogs)): ?> <?php if (!empty($deathAuditLogs)): ?>
<div class="card"> <div class="card" style="margin-bottom:20px;">
<div style="padding:15px 20px;border-bottom:1px solid #E5E7EB;"> <div style="padding:15px 20px;border-bottom:1px solid #E5E7EB;background:#F9FAFB;">
<h3 style="margin:0;font-size:16px;color:#1F2937;">سجل العمليات التفصيلي</h3> <h3 style="margin:0;font-size:16px;color:#1F2937;">&#x23f3; سجل العمليات التفصيلي — حالات الوفاة</h3>
</div> </div>
<div style="padding:20px;"> <div style="padding:20px;">
<div style="position:relative;padding-right:30px;"> <div style="position:relative;padding-right:30px;">
<div style="position:absolute;right:12px;top:0;bottom:0;width:2px;background:#E5E7EB;"></div> <div style="position:absolute;right:12px;top:0;bottom:0;width:2px;background:#E5E7EB;"></div>
<?php foreach ($auditLogs as $log): <?php foreach ($deathAuditLogs as $log):
$iconMap = [ $iconMap = [
'snapshot_taken' => '&#x1f4f7;', 'snapshot_taken' => '&#x1f4f7;', 'member_archived' => '&#x1f4e6;',
'member_archived' => '&#x1f4e6;', 'new_member_created' => '&#x2728;', 'children_transferred' => '&#x1f46a;',
'new_member_created' => '&#x2728;', 'temps_transferred' => '&#x1f465;', 'secondary_member_created' => '&#x1f4cc;',
'children_transferred' => '&#x1f46a;', 'installments_transferred' => '&#x1f4b3;', 'documents_linked' => '&#x1f4c4;',
'temps_transferred' => '&#x1f465;', 'subscriptions_created' => '&#x1f4c5;', 'transfer_completed' => '&#x2705;',
'secondary_member_created' => '&#x1f4cc;', 'case_completed' => '&#x2705;', 'spouse_deceased' => '&#x1f54a;', 'child_deceased' => '&#x1f54a;',
'installments_transferred' => '&#x1f4b3;',
'documents_linked' => '&#x1f4c4;',
'subscriptions_created' => '&#x1f4c5;',
'transfer_completed' => '&#x2705;',
'case_completed' => '&#x2705;',
'spouse_deceased' => '&#x1f54a;',
'child_deceased' => '&#x1f54a;',
]; ];
$icon = $iconMap[$log['action_type']] ?? '&#x25cf;'; $icon = $iconMap[$log['action_type']] ?? '&#x25cf;';
?> ?>
<div style="position:relative;margin-bottom:20px;padding-right:25px;"> <div style="position:relative;margin-bottom:16px;padding-right:25px;">
<div style="position:absolute;right:-6px;top:4px;width:24px;height:24px;background:#fff;border:2px solid #3B82F6;border-radius:50%;text-align:center;line-height:20px;font-size:12px;"><?= $icon ?></div> <div style="position:absolute;right:-6px;top:4px;width:24px;height:24px;background:#fff;border:2px solid #3B82F6;border-radius:50%;text-align:center;line-height:20px;font-size:12px;"><?= $icon ?></div>
<div style="background:#F9FAFB;border:1px solid #E5E7EB;border-radius:8px;padding:12px 15px;"> <div style="background:#F9FAFB;border:1px solid #E5E7EB;border-radius:8px;padding:10px 14px;">
<div style="font-weight:600;color:#1F2937;margin-bottom:4px;"><?= e($log['action_description_ar']) ?></div> <div style="font-weight:600;color:#1F2937;margin-bottom:3px;font-size:13px;"><?= e($log['action_description_ar']) ?></div>
<div style="font-size:12px;color:#6B7280;display:flex;gap:15px;flex-wrap:wrap;"> <div style="font-size:11px;color:#6B7280;display:flex;gap:12px;flex-wrap:wrap;">
<span><?= e($log['performed_at']) ?></span> <span><?= e($log['performed_at']) ?></span>
<?php if ($log['performer_name']): ?> <?php if (!empty($log['performer_name'])): ?>
<span>بواسطة: <?= e($log['performer_name']) ?></span> <span>بواسطة: <?= e($log['performer_name']) ?></span>
<?php endif; ?> <?php endif; ?>
<?php if ($log['affected_entity_type']): ?> <?php if (!empty($log['affected_entity_type'])): ?>
<span style="color:#9CA3AF;"><?= e($log['affected_entity_type']) ?> #<?= (int) $log['affected_entity_id'] ?></span> <span style="color:#9CA3AF;"><?= e($log['affected_entity_type']) ?> #<?= (int) $log['affected_entity_id'] ?></span>
<?php endif; ?> <?php endif; ?>
</div> </div>
...@@ -124,12 +287,32 @@ ...@@ -124,12 +287,32 @@
</div> </div>
</div> </div>
</div> </div>
<?php else: ?> <?php endif; ?>
<div class="card" style="padding:40px;text-align:center;">
<div style="font-size:48px;margin-bottom:10px;">&#x1f4cb;</div> <!-- ═══════ ARCHIVE SNAPSHOTS ═══════ -->
<p style="color:#6B7280;">لا يوجد سجل تأميني لهذا العضو</p> <?php if (!empty($snapshots)): ?>
<div class="card" style="margin-bottom:20px;">
<div style="padding:15px 20px;border-bottom:1px solid #E5E7EB;background:#F9FAFB;">
<h3 style="margin:0;font-size:16px;color:#1F2937;">&#x1f4e6; لقطات الأرشيف (<?= count($snapshots) ?>)</h3>
</div>
<div class="table-responsive" style="padding:10px;">
<table class="data-table" style="width:100%;font-size:13px;">
<thead><tr><th>#</th><th>السبب</th><th>رقم العضوية</th><th>تاريخ اللقطة</th></tr></thead>
<tbody>
<?php foreach ($snapshots as $snap): ?>
<tr>
<td style="font-weight:600;">#<?= (int) $snap['id'] ?></td>
<td><?= e($snap['snapshot_reason'] ?? '—') ?></td>
<td style="font-family:monospace;"><?= e($snap['membership_number'] ?? '—') ?></td>
<td><?= e(substr($snap['snapshot_taken_at'] ?? '', 0, 16)) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div> </div>
<?php endif; ?> <?php endif; ?>
<?php endif; ?>
</div> </div>
<?php $__template->endSection(); ?> <?php $__template->endSection(); ?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment