@extends('adminlte::page')
@section('title', 'Dashboard')
@include('partials.ui-polish')
@section('content_header')
HR & Payroll Dashboard
Today’s people operations, approvals, compliance, and payroll readiness
@if($activeModuleCodes->contains('leave_management') && Illuminate\Support\Facades\Gate::allows('hrm.view'))
Absence Calendar
@endif
@if($activeModuleCodes->contains('project_management') && Illuminate\Support\Facades\Gate::allows('projects.view'))
Projects
@endif
@if($activeModuleCodes->contains('payroll') && Illuminate\Support\Facades\Gate::allows('payroll.process'))
Payroll Runs
@endif
@stop
@section('content')
@php
$can = fn (string $ability) => Illuminate\Support\Facades\Gate::allows($ability);
$moduleIsActive = fn (string $module) => $activeModuleCodes->contains($module);
$canSeeLeaveStartingSoon = $moduleIsActive('leave_management') && ($can('hrm.manage') || $can('hrm.attendance.manage'));
$workQueueCount = ($moduleIsActive('leave_management') && $can('hrm.leave.supervisor-approve') ? $pendingLeaveRequests->count() : 0)
+ ($moduleIsActive('leave_management') && $can('hrm.leave.approve') ? $finalApprovalLeaveRequests->count() : 0)
+ ($canSeeLeaveStartingSoon ? $leaveStartingSoon->count() : 0)
+ ($moduleIsActive('timesheet_management') && $can('hrm.timesheets.manage') ? $pendingTimesheets->count() : 0)
+ ($moduleIsActive('payroll') && $can('payroll.process') ? $openPayrollRuns->count() : 0)
+ ($moduleIsActive('advance_retirement') && $can('advance.view') ? $metrics['pendingAdvances'] : 0)
+ ($moduleIsActive('hr_management') && $can('hrm.manage') ? $expiringContracts->count() : 0)
+ ($moduleIsActive('hr_management') && $can('hrm.manage') ? $expiringDocuments->count() : 0)
+ ($moduleIsActive('payroll') && $can('payroll.manage') ? $salaryGradeAlerts->count() : 0)
+ ($moduleIsActive('hr_management') && $can('hrm.manage') ? $upcomingHolidays->count() : 0);
$moduleCards = [
[
'title' => 'Platform',
'subtitle' => 'Tenants, plans, subscriptions',
'icon' => 'fas fa-globe',
'theme' => 'dark',
'metric' => $metrics['organizations'],
'metricLabel' => 'organizations',
'ability' => 'platform.manage',
'url' => route('admin.organizations.index'),
'actions' => [
['label' => 'Organizations', 'url' => route('admin.organizations.index'), 'ability' => 'platform.manage'],
['label' => 'Users', 'url' => route('admin.users.index'), 'ability' => 'users.manage'],
],
],
[
'title' => 'People',
'subtitle' => 'Employees, contracts, documents',
'icon' => 'fas fa-user-friends',
'theme' => 'primary',
'metric' => $metrics['activeEmployees'],
'metricLabel' => 'active staff',
'ability' => 'hrm.manage',
'module' => 'hr_management',
'url' => route('hrm.employees.index'),
'actions' => [
['label' => 'Employees', 'url' => route('hrm.employees.index'), 'ability' => 'hrm.manage', 'module' => 'hr_management'],
['label' => 'Contracts', 'url' => route('hrm.contracts.index'), 'ability' => 'hrm.manage', 'module' => 'hr_management'],
['label' => 'Documents', 'url' => route('hrm.documents.index'), 'ability' => 'hrm.manage', 'module' => 'hr_management'],
],
],
[
'title' => 'Leave & Time',
'subtitle' => 'Absences, attendance, timesheets',
'icon' => 'fas fa-calendar-check',
'theme' => 'success',
'metric' => $metrics['pendingLeave'] + $metrics['submittedTimesheets'],
'metricLabel' => 'items pending',
'ability' => 'hrm.view',
'module' => 'leave_management',
'url' => route('hrm.leave-requests.index'),
'actions' => [
['label' => 'Leave', 'url' => route('hrm.leave-requests.index'), 'ability' => 'hrm.leave.request', 'module' => 'leave_management'],
['label' => 'Attendance', 'url' => route('hrm.attendance.index'), 'ability' => 'hrm.attendance.manage', 'module' => 'timesheet_management'],
['label' => 'Timesheets', 'url' => route('hrm.timesheets.index'), 'ability' => 'hrm.timesheets.manage', 'module' => 'timesheet_management'],
],
],
[
'title' => 'Payroll',
'subtitle' => 'Salary setup, runs, payslips',
'icon' => 'fas fa-money-check-alt',
'theme' => 'info',
'metric' => $metrics['activeSalaries'],
'metricLabel' => 'salary records',
'ability' => 'payroll.payslip.view-own',
'module' => 'payroll',
'url' => route('payroll.runs.index'),
'actions' => [
['label' => 'Setup', 'url' => route('payroll.salary-setup.index'), 'ability' => 'payroll.manage', 'module' => 'payroll'],
['label' => 'Runs', 'url' => route('payroll.runs.index'), 'ability' => 'payroll.process', 'module' => 'payroll'],
['label' => 'Payslips', 'url' => route('payroll.payslips.index'), 'ability' => 'payroll.payslip.view-own', 'module' => 'payroll'],
],
],
[
'title' => 'Advance & Retirement',
'subtitle' => 'Requests, payments, settlements',
'icon' => 'fas fa-hand-holding-usd',
'theme' => 'teal',
'metric' => $metrics['pendingAdvances'],
'metricLabel' => 'pending requests',
'ability' => 'advance.view',
'module' => 'advance_retirement',
'url' => route('advance-retirement.index'),
'actions' => [
['label' => 'Requests', 'url' => route('advance-retirement.index'), 'ability' => 'advance.view', 'module' => 'advance_retirement'],
['label' => 'Pending', 'url' => route('advance-retirement.index'), 'ability' => 'advance.view', 'module' => 'advance_retirement'],
['label' => 'Retirement', 'url' => route('advance-retirement.index', ['status' => 'Partially Retired']), 'ability' => 'advance.view', 'module' => 'advance_retirement'],
],
],
[
'title' => 'Projects',
'subtitle' => 'Donors, budgets, work plans',
'icon' => 'fas fa-project-diagram',
'theme' => 'success',
'metric' => $metrics['activeProjects'],
'metricLabel' => 'active projects',
'ability' => 'projects.view',
'module' => 'project_management',
'url' => route('projects.index'),
'actions' => [
['label' => 'Dashboard', 'url' => route('projects.index'), 'ability' => 'projects.view', 'module' => 'project_management'],
['label' => 'Budgets', 'url' => route('projects.index', ['section' => 'budgets']), 'ability' => 'projects.view', 'module' => 'project_management'],
['label' => 'Activities', 'url' => route('projects.index', ['section' => 'activities']), 'ability' => 'projects.view', 'module' => 'project_management'],
],
],
[
'title' => 'Configuration',
'subtitle' => 'Leave rules, holidays, grades',
'icon' => 'fas fa-sliders-h',
'theme' => 'warning',
'metric' => $upcomingHolidays->count(),
'metricLabel' => 'holidays soon',
'ability' => 'hrm.manage',
'module' => 'hr_management',
'url' => route('hrm.configuration.index'),
'actions' => [
['label' => 'HR Config', 'url' => route('hrm.configuration.index'), 'ability' => 'hrm.manage', 'module' => 'hr_management'],
['label' => 'Structure', 'url' => route('hrm.structure.index'), 'ability' => 'hrm.manage', 'module' => 'hr_management'],
['label' => 'Users', 'url' => route('admin.users.index'), 'ability' => 'users.manage', 'module' => 'hr_management'],
],
],
];
$moduleCards = collect($moduleCards)
->filter(fn ($card) => Illuminate\Support\Facades\Gate::allows($card['ability'])
&& (empty($card['module']) || $moduleIsActive($card['module'])))
->map(function ($card) use ($moduleIsActive) {
$card['actions'] = collect($card['actions'])
->filter(fn ($action) => Illuminate\Support\Facades\Gate::allows($action['ability'])
&& (empty($action['module']) || $moduleIsActive($action['module'])))
->values()
->all();
return $card;
})
->values();
@endphp
@push('css')
@endpush
@if($moduleIsActive('hr_management') && $can('hrm.manage'))
@endif
@if($moduleIsActive('timesheet_management') && $can('hrm.attendance.manage'))
@endif
@if($moduleIsActive('leave_management') && $can('hrm.leave.request'))
@endif
@if($moduleIsActive('leave_management') && $can('hrm.leave.approve'))
@endif
@if($moduleIsActive('hr_management') && $can('hrm.manage'))
@endif
@if($moduleIsActive('payroll') && $can('payroll.manage'))
@endif
@if($moduleIsActive('payroll') && $can('payroll.payslip.view-own'))
@endif
@if($moduleIsActive('hr_management') && $can('hrm.manage'))
@endif