getYear(); $monthLabels = []; foreach ($data as $monthKey => $attendances) { $tsec = 0; foreach ($attendances as $attendance) { if (!empty($attendance->duration)) { [$h, $m, $s] = explode(':', $attendance->duration); $tsec += (int)$h * 3600 + (int)$m * 60 + (int)$s; } } $hours = floor($tsec / 3600); $minutes = floor(($tsec % 3600) / 60); $monthlyTotals[$monthKey] = sprintf('%02d:%02d', $hours, $minutes); if (preg_match('/^(\d{4})-(\d{2})$/', (string) $monthKey, $m)) { try { $j = new Jalalian((int) $m[1], (int) $m[2], 1); $name = $j->format('%B'); $monthLabels[$monthKey] = ((int) $m[1] === (int) $currentJalaliYear) ? $name : $name . ' ' . $m[1]; } catch (\Throwable $e) { $monthLabels[$monthKey] = $monthKey; } } else { $monthLabels[$monthKey] = $monthKey; } } $monthKeys = array_keys($data); $recentMonthKeys = array_slice($monthKeys, 0, 3); $olderMonthKeys = array_slice($monthKeys, 3); ?> @extends('app') @section('content')
@if(empty($data))

اطلاعاتی موجود نمیباشد

@else
@foreach($recentMonthKeys as $monthKey) @endforeach @if(!empty($olderMonthKeys))
@endif
@foreach($data as $monthKey => $records)
@foreach($records as $row) @endforeach
تاریخ روز ورود خروج مدت
{{ \App\Support\JalaliHelper::format($row->entered_at, 'Y/m/d') }} {{ \App\Support\JalaliHelper::format($row->entered_at, '%A') }} {{ Carbon::parse($row->entered_at)->format('H:i') ?? '-' }} {{ $row->exited_at ? Carbon::parse($row->exited_at)->format('H:i') : '-' }} {{ $row->exited_at ? Carbon::parse($row->duration)->format('H:i') : '-' }}
مجموع کارکرد این ماه: {{ $monthlyTotals[$monthKey] }}
@endforeach @endif
@endsection