@extends('layouts.backend') @section('content') @php $perms = $dashboardPermissions ?? []; $can = fn (string $permission): bool => $perms[$permission] ?? false; $scopeLabel = match ($dashboardScope ?? 'self') { 'all' => __('Company overview'), 'department' => __('Department overview'), default => __('Personal overview'), }; $visibleCards = collect($summaryCards ?? [])->filter(fn ($card) => $can($card['permission'] ?? ''))->values(); $attendance = $attendanceSummary ?? ['present' => 0, 'absent' => 0, 'late' => 0, 'leave' => 0]; $departmentRows = collect($departmentChart ?? []); @endphp

{{ __('Dashboard') }}

@include('partials.flash')
{{ __('HR dashboard') }}

{{ $scopeLabel }}

{{ __('Basic employee visibility, daily attendance, notices, notes, and upcoming events.') }}

{{ now()->format('l') }} {{ now()->format('M d, Y') }}
@if($visibleCards->isNotEmpty())
@foreach($visibleCards as $card)
{{ __($card['label']) }} {{ is_float($card['value']) ? number_format($card['value'], 1) : number_format((int) $card['value']) }}
@endforeach
@endif
@if($can('dashboard.attendance_chart'))

{{ ($dashboardScope ?? 'self') === 'self' ? __('My Monthly Attendance Summary') : __('Attendance Summary') }}

{{ __('Present, absent, late, and leave counts.') }}

@endif @if($can('dashboard.department_chart') && ($dashboardScope ?? 'self') !== 'self')

{{ __('Department-wise Employees') }}

{{ __('Active employee count by department.') }}

@endif @if($can('dashboard.today_attendance_table'))

{{ ($dashboardScope ?? 'self') === 'self' ? __('My Recent Attendance') : (($dashboardScope ?? 'self') === 'department' ? __('Today Team Attendance') : __('Today Attendance')) }}

{{ __('Latest attendance entries within your dashboard scope.') }}

@forelse(($todayAttendanceRows ?? collect()) as $row) @empty @endforelse
{{ __('Employee') }} {{ __('Department') }} {{ __('Status') }} {{ __('Check In') }} {{ __('Check Out') }}
{{ trim($row->employee?->first_name . ' ' . $row->employee?->last_name) ?: '-' }}
{{ $row->employee?->employee_code }}
{{ $row->employee?->department?->name ?? __('Unassigned') }} {{ __(ucfirst($row->status)) }} {{ $row->check_in_at?->format('h:i A') ?? '-' }} {{ $row->check_out_at?->format('h:i A') ?? '-' }}
{{ __('No attendance entries available.') }}
@endif
@if($can('dashboard.pending_leave_table'))

{{ ($dashboardScope ?? 'self') === 'self' ? __('My Leave Requests') : (($dashboardScope ?? 'self') === 'department' ? __('Team Pending Leave Requests') : __('Pending Leave Requests')) }}

{{ __('Open leave requests for this dashboard scope.') }}

@forelse(($pendingLeaveRows ?? collect()) as $leave) @empty @endforelse
{{ __('Employee') }} {{ __('Leave') }} {{ __('Dates') }} {{ __('Days') }}
{{ trim($leave->employee?->first_name . ' ' . $leave->employee?->last_name) ?: '-' }} {{ $leave->leaveCategory?->name ?? '-' }} {{ $leave->start_date ? \Illuminate\Support\Carbon::parse($leave->start_date)->format('M d') : '-' }} - {{ $leave->end_date ? \Illuminate\Support\Carbon::parse($leave->end_date)->format('M d') : '-' }} {{ number_format((float) $leave->total_days, 1) }}
{{ __('No pending leave requests.') }}
@endif
@if($can('dashboard.upcoming_events_table'))

{{ ($dashboardScope ?? 'self') === 'department' ? __('Upcoming Team Events') : __('Upcoming Holidays & Birthdays') }}

{{ __('Events in the next 45 days.') }}

@forelse(($upcomingEvents ?? collect()) as $event)
{{ __($event['type']) }}
{{ $event['title'] }}

{{ $event['date']?->format('M d') ?? '-' }} ยท {{ __($event['meta']) }}

@empty
{{ __('No upcoming holidays or birthdays.') }}
@endforelse
@endif
@if($can('dashboard.notice_board'))

{{ __('Notice Board') }}

{{ __('Published HR/Admin notices.') }}

@if($canViewAnnouncements ?? false) {{ __('View') }} @endif @if($canCreateAnnouncement ?? false) {{ __('Add') }} @endif
@forelse(($latestAnnouncements ?? collect()) as $item) {{ __(ucfirst($item->announcement_type)) }} {{ $item->title }} {{ $item->publish_at?->format('M d, Y') ?? __('Draft date unavailable') }} @empty
{{ __('No active notices available.') }}
@endforelse
@endif @if($can('dashboard.quick_notes'))

{{ __('Quick Notes') }}

{{ __('Private notes for your own follow-up.') }}

    @if(!($canViewPrivateNotes ?? false))
  • {{ __('You do not have permission to view private notes.') }}
  • @elseif(($privateNotes ?? collect())->isEmpty())
  • {{ __('No notes yet. Add your first private note below.') }}
  • @else @foreach(($privateNotes ?? collect()) as $note) @php($noteInputId = 'quick_note_' . $note->id)
  • @if($canUpdatePrivateNotes ?? false)
    @csrf @method('PATCH') is_completed ? 'checked' : '' }}>
    @endif
    {{ $note->title }}
    {{ $note->note_body }}
    @if($canUpdatePrivateNotes ?? false) @endif @if($canDeletePrivateNotes ?? false)
    @csrf @method('DELETE')
    @endif
  • @endforeach @endif
@if($canCreatePrivateNotes ?? false)
@csrf
@endif
@endif @if($can('dashboard.basic_alerts'))

{{ __('Basic Alerts') }}

{{ __('Simple items needing attention.') }}

@forelse(($basicAlerts ?? []) as $alert)
{{ $alert['label'] }}
@empty
{{ __('No alerts right now.') }}
@endforelse
@endif
@endsection @push('scripts') @endpush