@php if( request()->get('filter') && "this_month" == request()->get('filter') ) : $d = \Carbon\Carbon::parse('first day of this month'); $l = \Carbon\Carbon::parse('last day of this month'); $dayOfWeek = \Carbon\Carbon::parse('first day of this month')->dayOfWeek; $weekOfMonth = \Carbon\Carbon::parse('last day of this month')->weekOfMonth; elseif( request()->get('filter') && "last_month" == request()->get('filter') ) : $d = \Carbon\Carbon::parse('first day of previous month'); $l = \Carbon\Carbon::parse('last day of previous month'); $dayOfWeek = \Carbon\Carbon::parse('first day of previous month')->dayOfWeek; $weekOfMonth = \Carbon\Carbon::parse('last day of previous month')->weekOfMonth; else: $d = \Carbon\Carbon::today(); $l = \Carbon\Carbon::today(); $dayOfWeek = \Carbon\Carbon::today()->dayOfWeek; $weekOfMonth = \Carbon\Carbon::today()->weekOfMonth; endif; @endphp @foreach( $staffs as $staff )

{{ $staff->getName() ?? 'Guest' }}

@foreach( weekDays($dayOfWeek, true) as $day ) @endforeach @php $grandTotal = 0; @endphp @for($i = 0; $i < $weekOfMonth; $i++ ) @php $rowTotal = 0; @endphp @foreach( weekDays($dayOfWeek, true) as $key => $day ) @php $k = (int) $d->copy()->addWeeks($i)->addDays( $key )->format('Ymd'); @endphp @if( array_key_exists( $k, $staff->clock ) ) @php $clock_time = $staff->clock[$k]; @endphp @if( !empty( $clock_time ) && !empty($clock_time['total_time']) ) @else @endif @php $rowTotal += $clock_time['time']; @endphp @else @endif @endforeach @php if( $rowTotal > 60 ) { $grandTotal += $rowTotal; } @endphp @endfor
{{ ucfirst($day) }}Total
@if( $d->copy()->addWeeks($i)->addDays( $key )->lt($l) || $d->copy()->addWeeks($i)->addDays( $key )->eq($l) )
{{ $d->copy()->addWeeks($i)->addDays( $key )->format('d'); }}

{{ $clock_time['total_time'] ?? '' }}

@endif
@if( $d->copy()->addWeeks($i)->addDays( $key )->lt($l) || $d->copy()->addWeeks($i)->addDays( $key )->eq($l) )
{{ $d->copy()->addWeeks($i)->addDays( $key )->format('d'); }}

@endif
@if( $d->copy()->addWeeks($i)->addDays( $key )->lt($l) || $d->copy()->addWeeks($i)->addDays( $key )->eq($l) )
{{ $d->copy()->addWeeks($i)->addDays( $key )->format('d'); }}

@endif
@php $partsWeNeed = ( $rowTotal / 3600 ) > 1 ? 2 : 1; @endphp {{ $rowTotal > 60 ? \Carbon\CarbonInterval::seconds($rowTotal)->cascade() ->forHumans(['short' => true, 'join' => true, 'parts' => $partsWeNeed ]) : 0 }}
Grand Total @php $partsWeNeed = ( $grandTotal / 3600 ) > 1 ? 2 : 1; @endphp {{ $grandTotal > 60 ? \Carbon\CarbonInterval::seconds($grandTotal)->cascade() ->forHumans(['short' => true, 'join' => true, 'parts' => $partsWeNeed ]) : 0 }}
@endforeach