Commit 6ca3c4e9 authored by Mahmoud Aglan's avatar Mahmoud Aglan

fix(members): remove financial summary cards, add death case buttons for deceased dependents

1. Removed the green/blue financial summary stat cards (membership value + total paid)
   from member profile — only the "سجل المدفوعات" button remains
2. Deceased children and spouses now show a red "حالة الوفاة" button linking to
   their death case record
3. Deceased spouses now appear in the spouse table (were previously hidden by is_archived filter)
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 436658fe
...@@ -194,11 +194,11 @@ class MemberController extends Controller ...@@ -194,11 +194,11 @@ class MemberController extends Controller
FROM spouses s FROM spouses s
LEFT JOIN payment_requests pr ON pr.related_entity_type = 'spouses' AND pr.related_entity_id = s.id AND pr.payment_type = 'addition_fee' AND pr.is_voided = 0 LEFT JOIN payment_requests pr ON pr.related_entity_type = 'spouses' AND pr.related_entity_id = s.id AND pr.payment_type = 'addition_fee' AND pr.is_voided = 0
LEFT JOIN payments p ON p.id = s.activated_by_payment_id AND p.is_voided = 0 LEFT JOIN payments p ON p.id = s.activated_by_payment_id AND p.is_voided = 0
WHERE s.member_id = ? AND s.is_archived = 0 WHERE s.member_id = ? AND (s.is_archived = 0 OR s.status = 'deceased')
ORDER BY s.spouse_order", [(int) $id] ORDER BY s.is_archived ASC, s.spouse_order", [(int) $id]
); );
} catch (\Throwable $e) { } catch (\Throwable $e) {
try { $spouses = $db->select("SELECT * FROM spouses WHERE member_id = ? AND is_archived = 0 ORDER BY spouse_order", [(int) $id]); } catch (\Throwable $e2) {} try { $spouses = $db->select("SELECT * FROM spouses WHERE member_id = ? AND (is_archived = 0 OR status = 'deceased') ORDER BY is_archived ASC, spouse_order", [(int) $id]); } catch (\Throwable $e2) {}
} }
try { try {
$children = $db->select( $children = $db->select(
...@@ -372,6 +372,18 @@ class MemberController extends Controller ...@@ -372,6 +372,18 @@ class MemberController extends Controller
$cashDiscount = $bestOffer ? BoardOfferService::getCashDiscount($bill['total_pending'], $bestOffer) : null; $cashDiscount = $bestOffer ? BoardOfferService::getCashDiscount($bill['total_pending'], $bestOffer) : null;
$installmentTerms = BoardOfferService::getInstallmentTerms($bestOffer); $installmentTerms = BoardOfferService::getInstallmentTerms($bestOffer);
// Death cases for dependents (keyed by type:id)
$dependentDeathCases = [];
$depDeaths = $db->select(
"SELECT id, deceased_type, child_id, spouse_id, death_date, death_certificate_number, status
FROM death_cases WHERE member_id = ? AND deceased_type IN ('child', 'spouse') AND status = 'completed'",
[(int) $id]
);
foreach ($depDeaths as $dd) {
if ($dd['child_id']) $dependentDeathCases['child:' . $dd['child_id']] = $dd;
if ($dd['spouse_id']) $dependentDeathCases['spouse:' . $dd['spouse_id']] = $dd;
}
return $this->view('Members.Views.show', [ return $this->view('Members.Views.show', [
'member' => $member, 'member' => $member,
'branchName' => $branch['name_ar'] ?? '—', 'branchName' => $branch['name_ar'] ?? '—',
...@@ -406,6 +418,7 @@ class MemberController extends Controller ...@@ -406,6 +418,7 @@ class MemberController extends Controller
'overdueSubscriptions' => $overdueSubscriptions, 'overdueSubscriptions' => $overdueSubscriptions,
'transferFeePayment' => $transferFeePayment, 'transferFeePayment' => $transferFeePayment,
'separationTransfer' => $separationTransfer, 'separationTransfer' => $separationTransfer,
'dependentDeathCases' => $dependentDeathCases,
]); ]);
} }
......
...@@ -856,48 +856,16 @@ $hasIncomplete = !empty(array_filter($missingSteps, fn($s) => !$s['done'])); ...@@ -856,48 +856,16 @@ $hasIncomplete = !empty(array_filter($missingSteps, fn($s) => !$s['done']));
</table> </table>
</div> </div>
</div> </div>
<div class="card">
<?php if (can('member.view_financial')): ?> <?php if (can('member.view_financial')): ?>
<div style="padding:15px 20px;border-bottom:1px solid #E5E7EB;"><h3 style="margin:0;color:#0D7377;font-size:15px;"><i data-lucide="wallet" style="width:14px;height:14px;display:inline-block;vertical-align:middle;margin-left:4px;"></i> الملخص المالي</h3></div> <div class="card">
<div style="padding:15px 20px;"> <div style="padding:15px 20px;">
<div style="display:grid;grid-template-columns:<?= !empty($specialDiscount) ? '1fr 1fr 1fr' : '1fr 1fr' ?>;gap:15px;"> <a href="/payments/member/<?= (int) $member->id ?>" class="btn btn-outline" style="width:100%;text-align:center;"><i data-lucide="scroll-text" style="width:13px;height:13px;display:inline-block;vertical-align:middle;margin-left:3px;"></i> سجل المدفوعات</a>
<?php
$isTransferred = !empty($member->transferred_from_death_id) || !empty($member->transferred_from_waiver_id) || !empty($member->transferred_from_divorce_id) || !empty($member->transferred_from_transfer_id);
$displayValue = $member->membership_value ?? '0';
$valueLabel = 'قيمة العضوية';
if (!empty($member->transferred_from_transfer_id) && !empty($separationTransfer)) {
$displayValue = $transferFeePayment['amount'] ?? $separationTransfer['total_fee'] ?? $displayValue;
$valueLabel = 'رسوم الفصل المدفوعة';
} elseif ($isTransferred && !empty($transferFeePayment)) {
$displayValue = $transferFeePayment['amount'];
$valueLabel = 'المبلغ المدفوع عند الانتقال';
} elseif ($isTransferred && !empty($deathTransfer['paid_amount'])) {
$displayValue = $deathTransfer['paid_amount'];
$valueLabel = 'المبلغ المدفوع عند الانتقال';
}
?>
<div style="background:#F0FDF4;padding:15px;border-radius:8px;text-align:center;"><div style="font-size:20px;font-weight:700;color:#059669;"><?= money($displayValue) ?></div><div style="color:#6B7280;font-size:11px;"><?= $valueLabel ?></div></div>
<?php if (!empty($specialDiscount)): ?>
<div style="background:#FFF7ED;padding:15px;border-radius:8px;text-align:center;">
<div style="font-size:20px;font-weight:700;color:#D97706;">-<?= money($member->discount_amount ?? '0') ?></div>
<div style="color:#6B7280;font-size:11px;">خصم: <?= e($specialDiscount['name_ar']) ?> (<?= e($specialDiscount['discount_percentage']) ?>%)</div>
<?php if ($specialDiscount['requires_document'] && !empty($member->special_discount_document)): ?>
<a href="/<?= e($member->special_discount_document) ?>" target="_blank" style="font-size:11px;color:#0D7377;"><i data-lucide="file-text" style="width:11px;height:11px;display:inline-block;vertical-align:middle;margin-left:2px;"></i> عرض الإثبات</a>
<?php endif; ?>
</div>
<?php endif; ?>
<div style="background:#EFF6FF;padding:15px;border-radius:8px;text-align:center;"><div style="font-size:20px;font-weight:700;color:#0284C7;"><?= money($bill['total_paid']) ?></div><div style="color:#6B7280;font-size:11px;">إجمالي المدفوع</div></div>
</div>
<a href="/payments/member/<?= (int) $member->id ?>" class="btn btn-outline" style="width:100%;text-align:center;margin-top:10px;"><i data-lucide="scroll-text" style="width:13px;height:13px;display:inline-block;vertical-align:middle;margin-left:3px;"></i> سجل المدفوعات</a>
<?php if (!empty($deathTransfer['deceased_member_id'])): ?> <?php if (!empty($deathTransfer['deceased_member_id'])): ?>
<a href="/payments/member/<?= (int) $deathTransfer['deceased_member_id'] ?>" class="btn btn-outline" style="width:100%;text-align:center;margin-top:6px;color:#6B7280;border-color:#D1D5DB;"><i data-lucide="clipboard-list" style="width:13px;height:13px;display:inline-block;vertical-align:middle;margin-left:3px;"></i> سجل مدفوعات العضو المتوفي (<?= e($deathTransfer['deceased_member_name'] ?? '') ?>)</a> <a href="/payments/member/<?= (int) $deathTransfer['deceased_member_id'] ?>" class="btn btn-outline" style="width:100%;text-align:center;margin-top:6px;color:#6B7280;border-color:#D1D5DB;"><i data-lucide="clipboard-list" style="width:13px;height:13px;display:inline-block;vertical-align:middle;margin-left:3px;"></i> سجل مدفوعات العضو المتوفي (<?= e($deathTransfer['deceased_member_name'] ?? '') ?>)</a>
<?php endif; ?> <?php endif; ?>
</div> </div>
<?php else: ?>
<div style="padding:15px 20px;border-bottom:1px solid #E5E7EB;"><h3 style="margin:0;color:#0D7377;font-size:15px;"><i data-lucide="wallet" style="width:14px;height:14px;display:inline-block;vertical-align:middle;margin-left:4px;"></i> الملخص المالي</h3></div>
<div style="padding:30px;text-align:center;color:#9CA3AF;"><i data-lucide="lock" style="width:14px;height:14px;display:inline-block;vertical-align:middle;margin-left:4px;"></i> لا تملك صلاحية عرض البيانات المالية</div>
<?php endif; ?>
</div> </div>
<?php endif; ?>
</div> </div>
<!-- ═══════════════════════════════════════════════ --> <!-- ═══════════════════════════════════════════════ -->
...@@ -1108,8 +1076,9 @@ $childClassLabels = ['included' => 'تابع مشمول', 'dependent_with_fee' = ...@@ -1108,8 +1076,9 @@ $childClassLabels = ['included' => 'تابع مشمول', 'dependent_with_fee' =
if (!is_array($sBreakdown)) $sBreakdown = null; if (!is_array($sBreakdown)) $sBreakdown = null;
$_sHasPhoto = !empty($s['photo_path']); $_sHasPhoto = !empty($s['photo_path']);
$_sInitials = mb_substr($s['full_name_ar'], 0, 2); $_sInitials = mb_substr($s['full_name_ar'], 0, 2);
$_sIsDeceased = ($s['status'] ?? '') === 'deceased';
?> ?>
<tr <?= $sBreakdown ? 'style="cursor:pointer;" onclick="toggleBillDetail(\'spouse-' . $sIdx . '\')"' : '' ?>> <tr <?php if ($_sIsDeceased): ?>style="opacity:0.5;background:#F9FAFB;"<?php elseif ($sBreakdown): ?>style="cursor:pointer;" onclick="toggleBillDetail('spouse-<?= $sIdx ?>')"<?php endif; ?>>
<td><?= (int) $s['spouse_order'] ?></td> <td><?= (int) $s['spouse_order'] ?></td>
<td style="font-weight:600;"><div style="display:flex;align-items:center;gap:8px;"> <td style="font-weight:600;"><div style="display:flex;align-items:center;gap:8px;">
<div style="position:relative;flex-shrink:0;" class="dep-photo-wrap"> <div style="position:relative;flex-shrink:0;" class="dep-photo-wrap">
...@@ -1149,17 +1118,25 @@ $childClassLabels = ['included' => 'تابع مشمول', 'dependent_with_fee' = ...@@ -1149,17 +1118,25 @@ $childClassLabels = ['included' => 'تابع مشمول', 'dependent_with_fee' =
if ($sBreakdown) echo ' <small style="color:#0D7377;font-size:10px;">&#x25BC;</small>'; if ($sBreakdown) echo ' <small style="color:#0D7377;font-size:10px;">&#x25BC;</small>';
?></td> ?></td>
<td><?php <td><?php
$sIsDeceased = ($s['status'] ?? '') === 'deceased';
$sKey = 'spouses:' . (int) $s['id']; $sKey = 'spouses:' . (int) $s['id'];
$sInQueue = isset($pendingAdditions[$sKey]); $sInQueue = isset($pendingAdditions[$sKey]);
$sInCombined = ($s['status'] === 'pending_payment' && !empty($pendingMembership)); $sInCombined = ($s['status'] === 'pending_payment' && !empty($pendingMembership));
if ($sInQueue || $sInCombined): ?> if ($sIsDeceased): ?>
<span style="color:#DC2626;font-weight:600;font-size:12px;">&#x25cf; متوفية</span>
<?php elseif ($sInQueue || $sInCombined): ?>
<span style="color:#D97706;font-weight:600;font-size:12px;">&#x1f4b3; في الخزينة</span> <span style="color:#D97706;font-weight:600;font-size:12px;">&#x1f4b3; في الخزينة</span>
<?php else: ?> <?php else: ?>
<span style="color:<?= match($s['status']) { 'active' => '#059669', 'pending_payment' => '#D97706', default => '#DC2626' } ?>;font-weight:600;font-size:12px;">&#x25cf; <?= match($s['status']) { 'active' => 'نشط', 'pending_payment' => 'لم يتم السداد', 'inactive' => 'غير نشط', default => $s['status'] } ?></span> <span style="color:<?= match($s['status']) { 'active' => '#059669', 'pending_payment' => '#D97706', default => '#DC2626' } ?>;font-weight:600;font-size:12px;">&#x25cf; <?= match($s['status']) { 'active' => 'نشط', 'pending_payment' => 'لم يتم السداد', 'inactive' => 'غير نشط', default => $s['status'] } ?></span>
<?php endif; ?> <?php endif; ?>
</td> </td>
<td style="white-space:nowrap;"> <td style="white-space:nowrap;">
<?php if ($sIsDeceased && isset($dependentDeathCases['spouse:' . (int) $s['id']])): ?>
<?php $spouseDeath = $dependentDeathCases['spouse:' . (int) $s['id']]; ?>
<a href="/death/<?= (int) $spouseDeath['id'] ?>" class="btn btn-sm" style="background:#DC2626;color:#fff;border-color:#DC2626;font-size:11px;" title="تاريخ الوفاة: <?= e($spouseDeath['death_date']) ?>">حالة الوفاة</a>
<?php else: ?>
<a href="/members/<?= (int) $member->id ?>/spouses/<?= (int) $s['id'] ?>" class="btn btn-sm btn-outline">عرض</a> <a href="/members/<?= (int) $member->id ?>/spouses/<?= (int) $s['id'] ?>" class="btn btn-sm btn-outline">عرض</a>
<?php endif; ?>
</td> </td>
</tr> </tr>
<?php if ($sBreakdown): ?> <?php if ($sBreakdown): ?>
...@@ -1310,6 +1287,9 @@ $childClassLabels = ['included' => 'تابع مشمول', 'dependent_with_fee' = ...@@ -1310,6 +1287,9 @@ $childClassLabels = ['included' => 'تابع مشمول', 'dependent_with_fee' =
<td style="white-space:nowrap;"> <td style="white-space:nowrap;">
<?php if ($cIsSeparated && !empty($c['separated_member_id'])): ?> <?php if ($cIsSeparated && !empty($c['separated_member_id'])): ?>
<a href="/members/<?= (int) $c['separated_member_id'] ?>" class="btn btn-sm btn-outline" style="color:#0D7377;">الملف</a> <a href="/members/<?= (int) $c['separated_member_id'] ?>" class="btn btn-sm btn-outline" style="color:#0D7377;">الملف</a>
<?php elseif ($cIsDeceased && isset($dependentDeathCases['child:' . (int) $c['id']])): ?>
<?php $childDeath = $dependentDeathCases['child:' . (int) $c['id']]; ?>
<a href="/death/<?= (int) $childDeath['id'] ?>" class="btn btn-sm" style="background:#DC2626;color:#fff;border-color:#DC2626;font-size:11px;" title="تاريخ الوفاة: <?= e($childDeath['death_date']) ?>">حالة الوفاة</a>
<?php elseif (!$cIsInactive): ?> <?php elseif (!$cIsInactive): ?>
<a href="/members/<?= (int) $member->id ?>/children/<?= (int) $c['id'] ?>" class="btn btn-sm btn-outline">عرض</a> <a href="/members/<?= (int) $member->id ?>/children/<?= (int) $c['id'] ?>" class="btn btn-sm btn-outline">عرض</a>
<?php endif; ?> <?php endif; ?>
......
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