@extends('dashboard.layouts.app') @section('content') @include('components.alert') @php $currentMonth = now()->month; $currentYear = now()->year; $monthParam = request('month'); $yearParam = request('year'); $isAllMonth = ($monthParam === 'all'); $isAllYear = ($yearParam === 'all'); $selectedMonth = $isAllMonth ? null : (int) ($monthParam ?: $currentMonth); $selectedYear = $isAllYear ? null : (int) ($yearParam ?: $currentYear); $selectedMonthName = $selectedMonth ? date('F', mktime(0, 0, 0, $selectedMonth, 10)) : 'All months'; $selectedYearLabel = $selectedYear ? (string) $selectedYear : 'All years'; $canCheckRun = !is_null($selectedMonth) && !is_null($selectedYear); $runExistsForSelected = $canCheckRun ? DB::table('payroll_runs')->where('month', $selectedMonth)->where('year', $selectedYear)->exists() : null; $payrollRowsCount = !empty($rows) ? collect($rows)->count() : 0; @endphp
Payroll Period

Current payroll view is filtered by the selected month and year.

@if (!$canCheckRun) Showing {{ $selectedMonthName }} {{ $selectedYearLabel }} @else {{ $runExistsForSelected ? 'Run' : 'Not run' }} for {{ $selectedMonthName }} {{ $selectedYearLabel }} @endif
Total Gross Salaries
{{ number_format($totalGross, 2) }}
Total Net Salaries
{{ number_format($totalNet, 2) }}
Total Bonuses
{{ number_format($bonuses_total ?? 0, 2) }}
Total Penalties
{{ number_format($penalties_total ?? 0, 2) }}
Payroll Details Per Staff

Staff payroll records with pay period, run date, salary values, payment method, and payment status.

{{ $payrollRowsCount }} Staff Record(s)
@if (!empty($rows)) @forelse ($rows as $row) @php $staffName = $row->full_name ?: trim(($row->first_name ?? '') . ' ' . ($row->last_name ?? '')); $staffInitials = strtoupper( substr($row->first_name ?? 'S', 0, 1) . substr($row->last_name ?? '', 0, 1) ); $hasRunDate = !empty($row->run_date); @endphp
{{ $staffInitials ?: 'ST' }}
{{ $staffName ?: '—' }}
Staff Member
@if ($hasRunDate)
{{ \Carbon\Carbon::createFromDate($row->run_date)->firstOfMonth()->format('d-m-y') }} to {{ \Carbon\Carbon::createFromDate($row->run_date)->endOfMonth()->format('d-m-y') }}
@else — @endif @if ($hasRunDate) {{ \Illuminate\Support\Carbon::parse($row->run_date)->format('Y-m-d') }} @else — @endif {{ number_format($row->gross_salary, 2) }} {{ number_format($row->net_salary, 2) }} {{ $row->payment_type ?: '—' }} @if (isset($row->paid_at)) Paid @else @endif @empty
No payroll staff data found.

There are no payroll records matching the current period.

@endforelse @else
No payroll staff data found.

There are no payroll records matching the current period.

@endif Total {{ number_format($totalGross, 2) }} {{ number_format($totalNet, 2) }}
@endsection