@php if( !is_null($payrollSetting) ) { $ranges = getDateRanges( $payrollSetting->start_date, now(), $payrollSetting->payroll_type ); } if( request()->get('filter') && "this_week" == request()->get('filter') ) : // $d = \Carbon\Carbon::parse('this week monday'); // $dayOfWeek = \Carbon\Carbon::parse('this week monday')->dayOfWeek; // New Code With PayrollSetting if( !is_null($payrollSetting) && false !== $ranges && is_array($ranges) ) { $d = \Carbon\Carbon::parse( $ranges["cur"]["from"] ); $dayOfWeek = $d->dayOfWeek; } else { $d = now()->subDays(7); // Temp $dayOfWeek = now()->subDays(7)->dayOfWeek; // Temp } elseif( request()->get('filter') && "last_week" == request()->get('filter') ) : // $d = \Carbon\Carbon::parse('previous week monday'); // $dayOfWeek = \Carbon\Carbon::parse('previous week monday')->dayOfWeek; if( !is_null($payrollSetting) && false !== $ranges && is_array($ranges) ) { $d = \Carbon\Carbon::parse( $ranges["prev"]["from"] ); $dayOfWeek = $d->dayOfWeek; } else { $d = now()->subDays(21); // Temp $dayOfWeek = now()->subDays(21)->dayOfWeek; // Temp } else: $d = \Carbon\Carbon::today(); $dayOfWeek = \Carbon\Carbon::today()->dayOfWeek; endif; @endphp @foreach( $staffs as $staff )

{{ $staff->getName() ?? 'Guest' }} | Hourly Rate : {{ $staff->payment_type_hourly ? '$' . $staff->payment_type_hourly : 'N/A' }}

@foreach( weekDays($dayOfWeek, true) as $day ) @endforeach @php $grandTotal = $otGrandTotal = 0; @endphp @for( $i=0; $i < 2; $i++ ) @php $rowTotal = $otRowTotal = 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']; /* // Daily OT $rowTotal += $clock_time['time']; $regular_hours = $working_hours * 60 * 60; if( $clock_time['time'] > $regular_hours ) { $otRowTotal += $clock_time['time'] - $regular_hours; // Add OT } */ @endphp @else @endif @endforeach @php if( $rowTotal > 60 ) { $grandTotal += $rowTotal; $otGrandTotal += $otRowTotal; } @endphp @endfor
{{ ucfirst($day) }}Total
{{ $d->copy()->addWeeks($i)->addDays($key)->format('M d') }}
{{ $clock_time['total_time'] }}
@if( in_array($k, $staff->shifts) )
{{ 'System generated' }}
@endif
{{ $d->copy()->addWeeks($i)->addDays($key)->format('M d') }}
{{ 'Inaccurate' }}
@if( in_array($k, $staff->shifts) )
{{ 'System generated' }}
@endif
{{ $d->copy()->addWeeks($i)->addDays($key)->format('M d') }}
{{ '0h 0m' }}
@if( in_array($k, $staff->shifts) )
{{ 'System generated' }}
@endif
@php $partsWeNeed = ( $rowTotal / 3600 ) > 1 ? 2 : 1; @endphp @php $hours = floor($rowTotal / 3600); $mins = floor($rowTotal / 60 % 60); echo timeDiffInHoursAndMins($hours, $mins); @endphp {{-- $rowTotal > 60 ? \Carbon\CarbonInterval::seconds($rowTotal)->cascade() ->forHumans(['short' => true, 'join' => true, 'parts' => $partsWeNeed ]) : 0 --}}

@if( false && $otRowTotal > 60 ) {{ '(OT:' }} @php /* // Daily OT $hours = floor($otRowTotal / 3600); $mins = floor($otRowTotal / 60 % 60); echo timeDiffInHoursAndMins($hours, $mins); */ @endphp {{ ')' }} @endif @if( $rowTotal > 60 ) {{ '(OT:' }} @php $regular_hours = $weekly_hours * 60 * 60; if( $rowTotal > $regular_hours ) { $otRowTotal += $rowTotal - $regular_hours; // Add OT } $hours = floor($otRowTotal / 3600); $mins = floor($otRowTotal / 60 % 60); echo timeDiffInHoursAndMins($hours, $mins); @endphp {{ ')' }} @endif
Bi-Week Hours: @php if ($grandTotal < 3600) { $formattedTime = $grandTotal > 60 ? \Carbon\CarbonInterval::seconds($grandTotal)->cascade()->forHumans(['short' => true, 'join' => true, 'parts' => $partsWeNeed]) : '0s'; // Set to '0s' if less than 60 seconds } else { $hours = floor($grandTotal / 3600); $minutes = floor(($grandTotal % 3600) / 60); $formattedTime = $hours . 'h'; if ($minutes > 0) { $formattedTime .= ' ' . $minutes . 'm'; } } @endphp {{ $formattedTime }} Bi-Week Tip:${{ number_format(round( $grandTotal * $dollorPerSec, 2 ), 2 ) }} Bi-Week Pay: @if( isset($staff->payment_type_hourly) && $staff->payment_type_hourly > 0 ) @php $per_hour = $staff->payment_type_hourly; $hours = floor($grandTotal / 3600); $mins = floor($grandTotal / 60 % 60); // Calculate the total amount $total_amount = round($hours * $per_hour + $mins * ($per_hour / 60), 2); // Format the total amount to always have two digits after the decimal point $formatted_amount = number_format($total_amount, 2); echo '$' . $formatted_amount; @endphp @else {{ 'N/A' }} @endif OT: @if( isset($staff->payment_type_hourly) && $staff->payment_type_hourly > 0 ) @php $per_hour = $staff->payment_type_hourly; $hours = floor($otGrandTotal / 3600); $mins = floor($otGrandTotal / 60 % 60); // Calculate the total amount $total_amount = round($hours * $per_hour + $mins * ($per_hour / 60), 2) * 1.5; // Format the total amount to always have two digits after the decimal point $formatted_amount = number_format($total_amount, 2); echo '$' . $formatted_amount; @endphp @else {{ 'N/A' }} @endif 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 --}} @if( isset($staff->payment_type_hourly) && $staff->payment_type_hourly > 0 ) @php $per_hour = $staff->payment_type_hourly; $hours = floor($grandTotal / 3600); $mins = floor($grandTotal / 60 % 60); // Calculate the total amount $total_amount = round($hours * $per_hour + $mins * ($per_hour / 60), 2); $total_amount += round( $grandTotal * $dollorPerSec, 2 ); // Add tip amount // Format the total amount to always have two digits after the decimal point $formatted_amount = number_format($total_amount, 2); echo '$' . $formatted_amount; @endphp @else {{ 'N/A' }} @endif
@endforeach