@extends('layouts.app') @section('title', 'Monthly Report — ' . $report->period_label) @section('breadcrumbs') @endsection @section('content') @php $summary = $data['executive_summary'] ?? []; $hrActivities = $data['hr_activities'] ?? []; $attendance = $data['attendance_summary'] ?? []; $leave = $data['leave_summary'] ?? []; $payroll = $data['payroll_summary'] ?? []; $compliance = $data['compliance_status'] ?? []; $upcoming = $data['upcoming_actions'] ?? []; @endphp
{{-- Header --}}

Monthly Report: {{ $report->period_label }}

Generated {{ $report->generated_at?->format('d M Y H:i') ?? '' }} by {{ $report->generator?->name ?? 'System' }} {{ ucfirst($report->status) }}

Download PDF @if(auth()->user()->role === 'company_admin') @if($report->status === 'draft')
@csrf
@else
@csrf
@endif @endif
{{-- Section 1: Executive Summary --}}

1. Executive Summary

{{ $summary['employees_start'] ?? 0 }}
Start of Month
{{ $summary['employees_end'] ?? 0 }}
End of Month
+{{ $summary['new_hires'] ?? 0 }}
New Hires
-{{ $summary['exits'] ?? 0 }}
Exits
{{ $summary['attendance_rate'] ?? 0 }}%
Attendance Rate
{{ $summary['total_leave_days'] ?? 0 }}
Leave Days
{{-- Section 2: HR Activities --}}

2. HR Activities by TalentArabian

{{ $hrActivities['summary']['total_actions'] ?? 0 }} total actions
@php $actSummary = $hrActivities['summary'] ?? []; @endphp
@foreach([ ['label' => 'Onboarding', 'key' => 'onboarding', 'icon' => 'user-plus'], ['label' => 'Letters Issued', 'key' => 'letters_issued', 'icon' => 'file-text'], ['label' => 'Leave Processed', 'key' => 'leave_processed', 'icon' => 'calendar'], ['label' => 'Attendance Uploads', 'key' => 'attendance_uploads', 'icon' => 'upload'], ['label' => 'Payroll Processed', 'key' => 'payroll_processed', 'icon' => 'dollar-sign'], ['label' => 'Documents Managed', 'key' => 'documents_managed', 'icon' => 'folder'], ['label' => 'Status Changes', 'key' => 'status_changes', 'icon' => 'refresh-cw'], ['label' => 'Exit Processes', 'key' => 'exit_processes', 'icon' => 'log-out'], ['label' => 'Notices Posted', 'key' => 'notices_posted', 'icon' => 'bell'], ] as $act)
{{ $actSummary[$act['key']] ?? 0 }}
{{ $act['label'] }}
@endforeach
{{-- Recent Activities --}} @if(!empty($hrActivities['recent_activities']))

Recent Activity Log

@foreach(array_slice($hrActivities['recent_activities'], 0, 15) as $activity)
{{ $activity['date'] }}
{{ $activity['description'] }}
@endforeach
@endif
{{-- Section 3: Attendance Summary --}}

3. Attendance Summary

{{ $attendance['attendance_percentage'] ?? 0 }}%
Overall Rate
{{ $attendance['total_present'] ?? 0 }}
Present Days
{{ $attendance['total_late'] ?? 0 }}
Late Arrivals
{{ $attendance['total_overtime_hours'] ?? 0 }}
Overtime Hours
@if(!empty($attendance['department_breakdown']))

Department Breakdown

@foreach($attendance['department_breakdown'] as $dept) @endforeach
DepartmentPresentAbsentLateRate
{{ $dept['name'] ?? '—' }} {{ $dept['present'] ?? 0 }} {{ $dept['absent'] ?? 0 }} {{ $dept['late'] ?? 0 }} {{ $dept['rate'] ?? 0 }}%
@endif
{{-- Section 4: Leave Summary --}}

4. Leave Summary

{{ $leave['total_requests'] ?? 0 }}
Total Requests
{{ $leave['approved'] ?? 0 }}
Approved
{{ $leave['rejected'] ?? 0 }}
Rejected
{{ $leave['total_days'] ?? 0 }}
Total Days
@if(!empty($leave['by_type']))

By Leave Type

@foreach($leave['by_type'] as $type => $info)
{{ $type }} {{ is_array($info) ? ($info['days'] ?? $info['count'] ?? 0) : $info }} days
@endforeach
@endif
{{-- Section 5: Payroll Summary --}}

5. Payroll Summary

{{ ucfirst($payroll['status'] ?? 'Not Processed') }}
@if(($payroll['status'] ?? 'not_processed') !== 'not_processed' && ($payroll['status'] ?? '') !== 'unavailable')
{{ $payroll['employee_count'] ?? 0 }}
Employees
OMR {{ number_format($payroll['total_earnings'] ?? 0, 3) }}
Total Earnings
OMR {{ number_format($payroll['total_deductions'] ?? 0, 3) }}
Total Deductions
OMR {{ number_format($payroll['total_net'] ?? 0, 3) }}
Net Disbursed
@if(!empty($payroll['wps_status']))

WPS Status: {{ ucfirst(str_replace('_', ' ', $payroll['wps_status'])) }}

@endif @else

Payroll has not been processed for this period.

@endif
{{-- Section 6: Compliance Status --}}

6. Compliance Status

@php $oman = $compliance['omanization'] ?? []; $score = $compliance['compliance_score'] ?? []; @endphp

Omanization

{{ number_format($oman['ratio'] ?? 0, 1) }}%
Current
/
{{ number_format($oman['required'] ?? 0, 1) }}%
Required
{{ ($oman['is_compliant'] ?? false) ? 'Compliant' : 'Non-Compliant' }}

Document Compliance

{{ $score['score'] ?? 0 }}%
Score

{{ $score['valid'] ?? 0 }} valid, {{ $score['expiring'] ?? 0 }} expiring, {{ $score['expired'] ?? 0 }} expired

@if(!empty($compliance['expiring_documents']))

Documents Expiring Soon

@foreach($compliance['expiring_documents'] as $doc)
{{ $doc['type'] }} {{ $doc['number'] ? '#' . $doc['number'] : '' }} {{ $doc['days_until_expiry'] }} days ({{ $doc['expiry_date'] }})
@endforeach
@endif
{{-- Section 7: Upcoming Actions --}} @if(count($upcoming) > 0)

7. Upcoming Actions

{{ count($upcoming) }} items
@foreach($upcoming as $action)
{{ $action['label'] }}

{{ $action['description'] }}

@endforeach
@endif
@endsection