@stack('styles')
@php // Get pending applications count based on user role $currentUser = Auth::user(); $userRole = $currentUser->employee->role->role ?? null; $pendingApplications = collect(); $pendingCount = 0; if ($userRole === 'representative') { // Representative: Only their own pending applications $pendingApplications = App\Models\DeductionsApplication::where('user_id', $currentUser->id) ->where('status', 'pending') ->with(['user', 'branch', 'district']) ->orderBy('created_at', 'desc') ->take(5) ->get(); } elseif ($userRole === 'manager') { // Manager: All pending applications from districts in their branch $userBranchId = $currentUser->employee->district->branch_id ?? null; if ($userBranchId) { $districtIds = App\Models\District::where('branch_id', $userBranchId)->pluck('id'); $pendingApplications = App\Models\DeductionsApplication::whereIn('district_id', $districtIds) ->where('status', 'pending') ->with(['user', 'branch', 'district']) ->orderBy('created_at', 'desc') ->take(5) ->get(); } } elseif ($userRole === 'admin') { // Admin: All pending applications $pendingApplications = App\Models\DeductionsApplication::where('status', 'pending') ->with(['user', 'branch', 'district']) ->orderBy('created_at', 'desc') ->take(5) ->get(); } $pendingCount = $pendingApplications->count(); @endphp

Maombi Yanayosubiri

{{ $pendingCount }} {{ $pendingCount == 1 ? 'ombi' : 'maombi' }}
@forelse($pendingApplications as $application)

@if($userRole !== 'representative') {{ $application->names }} @else Ombi lako la makato @endif

Check: {{ $application->check_number }}
@if($userRole !== 'representative')
Wilaya: {{ ucfirst($application->district->name ?? 'N/A') }} @if($userRole === 'admin') Tawi: {{ ucfirst($application->district->branch->name ?? 'N/A') }} @endif
@endif

{{ $application->created_at->diffForHumans() }}

TSh {{ number_format($application->new_contribution_amount, 2) }}
@empty
assignment_turned_in

Hakuna maombi yanayosubiri

Maombi yote yameshatatuliwa

@endforelse
@if($pendingCount > 0) @endif
@php // Get current user's role and related data $currentUser = Auth::user(); $userRole = $currentUser->employee->role->role ?? null; // Get notifications based on role $notifications = collect(); $notificationCount = 0; if ($userRole === 'representative') { // Representative: Only their own records $notifications = App\Models\DeductionsApplication::where('user_id', $currentUser->id) ->with(['user', 'branch', 'district']) ->orderBy('created_at', 'desc') ->take(5) ->get(); } elseif ($userRole === 'manager') { // Manager: All records from districts in their branch $userBranchId = $currentUser->employee->district->branch_id ?? null; if ($userBranchId) { $districtIds = App\Models\District::where('branch_id', $userBranchId)->pluck('id'); $notifications = App\Models\DeductionsApplication::whereIn('district_id', $districtIds) ->with(['user', 'branch', 'district']) ->orderBy('created_at', 'desc') ->take(5) ->get(); } } elseif ($userRole === 'admin') { // Admin: All records $notifications = App\Models\DeductionsApplication::with(['user', 'branch', 'district']) ->orderBy('created_at', 'desc') ->take(5) ->get(); } $notificationCount = $notifications->count(); @endphp

Arifa

@forelse($notifications as $notification)
@php $statusColor = match($notification->status) { 'pending' => 'bg-yellow-500', 'approved' => 'bg-green-500', 'rejected' => 'bg-red-500', default => 'bg-blue-500' }; $statusText = match($notification->status) { 'pending' => 'Ombi jipya la makato', 'approved' => 'Ombi limeidhinishwa', 'rejected' => 'Ombi limekataliwa', default => 'Ombi la makato' }; @endphp

{{ $statusText }}

@if($userRole !== 'representative')
{{ $notification->names }} ({{ $notification->check_number }})
@if($userRole === 'admin')
{{ ucfirst($notification->district->branch->name ?? 'N/A') }}
@endif @else
Ombi lako ({{ $notification->check_number }})
@endif

{{ $notification->created_at->diffForHumans() }}

@empty
notifications_none

Hakuna arifa mpya

@endforelse
@if($notificationCount > 0) @endif
person

{{ Auth::user()->name ?? 'Mtumiaji' }}

{{ Auth::user()->email ?? 'user@example.com' }}

settings Password Manager
@csrf
@yield('content')
add
@stack('scripts')