@section('page-title', 'Contracts Report') {{-- Using fully-qualified class name for Currency to avoid import in Blade (Blade templates compile inside a function) --}}

{{ __('Contracts Report') }}

{{ __('Filter and export contract records') }}

← {{ __('Back to Reports') }}
{{ __('Clear') }}

{{ __('Active Contracts') }}

{{ $activeContracts }}

{{ __('Expiring Soon') }} (30 {{ __('days') }})

{{ $expiringSoon }}

{{ $contracts->unique('employee_id')->count() }} {{ __('contract records found') }}

@php // Show one contract per employee — latest contract first $uniqueContracts = $contracts->sortByDesc('start_date')->unique('employee_id'); @endphp @forelse($uniqueContracts as $contract) @empty @endforelse
{{ __('Employee') }} {{ __('Type') }} {{ __('Position') }} {{ __('Start Date') }} {{ __('End Date') }} {{ __('Salary') }} {{ __('Status') }}
{{ $contract->employee->first_name ?? '' }} {{ $contract->employee->last_name ?? '' }} {{ ucfirst($contract->contract_type) }} {{ $contract->position }} {{ $contract->start_date->format('M d, Y') }} {{ $contract->end_date ? $contract->end_date->format('M d, Y') : 'Ongoing' }} {{-- Contract model does not store salary; use employee base_salary instead. Convert base_salary to the configured base local currency using the base currency exchange_rate. --}} @php $baseCurrency = \App\Models\Currency::base(); $baseSalary = $contract->employee->base_salary ?? 0; if ($baseCurrency && $baseCurrency->exchange_rate && $baseCurrency->exchange_rate > 0) { $localSalary = (float)$baseSalary * (float)$baseCurrency->exchange_rate; // Show only the target currency code/name (to_currency) instead of combined identifiers like "USD_TZS" $symbol = $baseCurrency->to_currency ?? $baseCurrency->code ?? ''; } else { // Fallback: show stored base salary (assumed USD) and use a simple USD code $localSalary = $baseSalary; $symbol = 'USD'; } @endphp {{ $symbol }} {{ number_format($localSalary, 2) }} @php $status = $contract->status; $color = 'gray'; if($contract->status === 'active' && $contract->end_date && $contract->end_date < now()) { $status = 'expired'; $color = 'red'; } elseif($contract->status === 'active') { $color = 'green'; } elseif($contract->status === 'terminated') { $color = 'orange'; } @endphp {{ ucfirst($status) }}
{{ __('No contract records found.') }}