@extends('layouts.app') @section('title', 'تقارير الرواتب المتقدمة') @section('content')
{{-- مقارنة الشهر الحالي مع السابق --}}
@php $comparisons = [ ['label' => 'صافي الرواتب', 'current' => $currentTotals['net'], 'prev' => $prevTotals['net'], 'icon' => 'fa-money-bill-wave', 'color' => 'var(--success)'], ['label' => 'إجمالي البدلات', 'current' => $currentTotals['allowances'], 'prev' => $prevTotals['allowances'], 'icon' => 'fa-plus-circle', 'color' => 'var(--primary)'], ['label' => 'إجمالي الخصومات', 'current' => $currentTotals['deductions'], 'prev' => $prevTotals['deductions'], 'icon' => 'fa-minus-circle', 'color' => 'var(--danger)'], ['label' => 'عدد الموظفين', 'current' => $currentTotals['count'], 'prev' => $prevTotals['count'], 'icon' => 'fa-users', 'color' => 'var(--warning)'], ]; @endphp @foreach($comparisons as $comp) @php $diff = $comp['current'] - $comp['prev']; $pctChange = $comp['prev'] > 0 ? round(($diff / $comp['prev']) * 100, 1) : 0; @endphp
{{ $comp['label'] === 'عدد الموظفين' ? $comp['current'] : number_format($comp['current'], 0) }}
{{ $comp['label'] }}
@if($pctChange != 0) {{ abs($pctChange) }}% عن الشهر السابق @endif
@endforeach
{{-- اتجاه الرواتب (6 أشهر) --}}

اتجاه صافي الرواتب (6 أشهر)

@php $maxM = max(1, max(array_column($monthlyTrend, 'total'))); @endphp @foreach($monthlyTrend as $mt)
{{ number_format($mt['total']/1000, 0) }}K
{{ \Carbon\Carbon::parse($mt['month'] . '-01')->format('M') }}
@endforeach
{{-- تحليل البدلات --}}

تحليل البدلات

@php $totalAll = array_sum($allowanceBreakdown) ?: 1; $allLabels = ['housing' => 'بدل السكن', 'transport' => 'بدل النقل', 'other' => 'بدلات أخرى']; $allColors = ['housing' => 'var(--primary)', 'transport' => 'var(--success)', 'other' => 'var(--warning)']; @endphp @foreach($allowanceBreakdown as $key => $val) @php $pct = round(($val / $totalAll) * 100, 1); @endphp
{{ $allLabels[$key] }} {{ number_format($val, 0) }} ({{ $pct }}%)
@endforeach
{{-- تكلفة لكل قسم --}}

تكلفة الرواتب حسب القسم

@foreach($departmentCosts as $deptName => $data) @php $pct = $currentTotals['net'] > 0 ? round(($data['net'] / $currentTotals['net']) * 100, 1) : 0; @endphp @endforeach
القسم عدد الموظفين الأساسي البدلات الخصومات الصافي النسبة
{{ $deptName }} {{ $data['count'] }} {{ number_format($data['basic'], 0) }} {{ number_format($data['allowances'], 0) }} {{ number_format($data['deductions'], 0) }} {{ number_format($data['net'], 0) }} {{ $pct }}%
@endsection