Commit 7fd089ad authored by Mahmoud Aglan's avatar Mahmoud Aglan

Fix 4 manager-reported report issues

1. Status/gender/method columns now display Arabic labels instead of raw English values
2. Enrollment search (receptionist wizard) includes 'registered' participants, not just 'active'
3. New report: participants without medical clearance (بدون شهادة طبية)
4. Expired memberships report no longer crashes when date field is cleared (empty string fallback)
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 63b67cb9
......@@ -198,6 +198,9 @@ public function participantsByGender(?int $branchId = null): Collection
public function expiredMemberships(string $from, string $to, ?int $branchId = null): Collection
{
$from = $from ?: now()->startOfYear()->format('Y-m-d');
$to = $to ?: now()->format('Y-m-d');
return Participant::with(['person', 'branch'])
->where('membership_type', 'member')
->whereBetween('membership_expires_at', [$from, $to])
......@@ -215,6 +218,27 @@ public function expiredMemberships(string $from, string $to, ?int $branchId = nu
]);
}
public function withoutMedicalClearance(?int $branchId = null): Collection
{
return Participant::with(['person', 'branch'])
->whereIn('status', ['registered', 'active'])
->where(function ($q) {
$q->where('medical_clearance', false)
->orWhereNull('medical_clearance');
})
->when($branchId, fn ($q) => $q->where('branch_id', $branchId))
->orderBy('created_at', 'desc')
->get()
->map(fn ($p) => [
'name' => $p->person?->name_ar ?? '',
'phone' => $p->person?->phone ?? '',
'status' => $p->status?->value ?? $p->status,
'branch' => $p->branch?->name_ar ?? '',
'registration_date' => $p->registration_date?->format('Y-m-d') ?? $p->created_at?->format('Y-m-d'),
'clearance_expires' => $p->medical_clearance_expires?->format('Y-m-d') ?? '—',
]);
}
public function frozenAndSuspended(?int $branchId = null): Collection
{
return Participant::with(['person', 'branch'])
......
......@@ -188,7 +188,7 @@ public function render()
$searchResults = Participant::query()
->with('person')
->where('branch_id', $this->branchId)
->where('status', 'active')
->whereIn('status', ['active', 'registered'])
->where(function ($q) {
$search = $this->search;
$q->where('participant_number', 'ilike', "%{$search}%")
......
......@@ -143,6 +143,14 @@ public function getReportConfig(): array
'money_cols' => [],
'uses_dates' => true,
],
'without_medical_clearance' => [
'name' => 'مشتركون بدون شهادة طبية',
'method' => 'withoutMedicalClearance',
'headers' => ['الاسم', 'الهاتف', 'الحالة', 'الفرع', 'تاريخ التسجيل', 'انتهاء الشهادة'],
'columns' => ['name', 'phone', 'status', 'branch', 'registration_date', 'clearance_expires'],
'money_cols' => [],
'uses_dates' => false,
],
'frozen_suspended' => [
'name' => 'المجمدون والموقوفون',
'method' => 'frozenAndSuspended',
......@@ -307,7 +315,9 @@ public function render(ReportService $reportService)
$usesDates = $config['uses_dates'] ?? true;
if ($usesDates) {
$data = $reportService->$method($this->from, $this->to, $branchId);
$from = $this->from ?: now()->startOfMonth()->format('Y-m-d');
$to = $this->to ?: now()->format('Y-m-d');
$data = $reportService->$method($from, $to, $branchId);
} else {
$data = $reportService->$method($branchId);
}
......
......@@ -45,6 +45,7 @@ public function getReportsProperty(): array
['key' => 'by_age', 'name' => 'حسب الفئة العمرية', 'desc' => 'المشتركون النشطون مصنفين بالعمر'],
['key' => 'by_gender', 'name' => 'حسب الجنس', 'desc' => 'عدد الذكور والإناث النشطين'],
['key' => 'expired_memberships', 'name' => 'العضويات المنتهية', 'desc' => 'أعضاء تنتهي أو انتهت عضويتهم قريباً'],
['key' => 'without_medical_clearance', 'name' => 'بدون شهادة طبية', 'desc' => 'مشتركون نشطون بدون شهادة طبية سارية'],
['key' => 'frozen_suspended', 'name' => 'المجمدون والموقوفون', 'desc' => 'مشتركون متوقفون مع السبب والمدة'],
],
],
......
......@@ -66,9 +66,48 @@ class="w-full rounded-lg border-gray-300 shadow-sm focus:border-blue-500 focus:r
@php
$value = is_array($row) ? ($row[$col] ?? '') : ($row->$col ?? '');
$isMoney = in_array($col, $config['money_cols'] ?? []);
$statusLabels = [
'registered' => 'مسجل',
'active' => 'نشط',
'frozen' => 'مجمد',
'suspended' => 'موقوف',
'inactive' => 'غير نشط',
'graduated' => 'متخرج',
'transferred' => 'محوّل',
'withdrawn' => 'منسحب',
'blacklisted' => 'محظور',
'pending' => 'معلق',
'completed' => 'مكتمل',
'cancelled' => 'ملغي',
'expired' => 'منتهي',
'waitlisted' => 'قائمة الانتظار',
'confirmed' => 'مؤكد',
'failed' => 'فشل',
'refunded' => 'مسترد',
'draft' => 'مسودة',
'sent' => 'مرسلة',
'paid' => 'مدفوعة',
'partially_paid' => 'مدفوعة جزئياً',
'overdue' => 'متأخرة',
'scheduled' => 'مجدولة',
'in_progress' => 'جارية',
'rescheduled' => 'مُعاد جدولتها',
'male' => 'ذكر',
'female' => 'أنثى',
'open' => 'مفتوحة',
'closed' => 'مغلقة',
'cash' => 'نقدي',
'card' => 'بطاقة',
'bank_transfer' => 'تحويل بنكي',
'wallet' => 'محفظة',
'online' => 'إلكتروني',
'cheque' => 'شيك',
];
@endphp
@if($isMoney)
<span dir="ltr">{{ number_format($value / 100, 2) }}</span>
@elseif(in_array($col, ['status', 'gender', 'method', 'payment_method']) && is_string($value) && isset($statusLabels[$value]))
{{ $statusLabels[$value] }}
@else
{{ $value }}
@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