@extends('layouts.customer') @section('content') @php $payroll_type = $payrollSetting->payroll_type; $start_day = $payrollSetting->start_day; if($payroll_type == 'biweekly'){ // Get the current date $currentDate = date('Y-m-d'); // Get the start date of the pay period from your model $payStartDate = $payrollSetting->start_date; // Calculate the number of days between the start date and the current date $daysDifference = floor((strtotime($currentDate) - strtotime($payStartDate)) / (60 * 60 * 24)); // Calculate the pay period (assuming biweekly) $payPeriod = floor($daysDifference / 14) + 1; // Calculate the start and end dates of the current pay period $currentPayStartDate = date('Y-m-d', strtotime($payStartDate . ' +' . (($payPeriod - 1) * 14) . ' days')); $currentPayEndDate = date('Y-m-d', strtotime($currentPayStartDate . ' +13 days')); // Get the last pay period's start date $lastPayStartDate = date('Y-m-d', strtotime($currentPayStartDate . ' -14 days')); // Calculate the end date of the last pay period $lastPayEndDate = date('Y-m-d', strtotime($lastPayStartDate . ' +13 days')); } if($payroll_type == 'weekly'){ // Get the current date $currentDate = date('Y-m-d'); // Get the start date of the pay period from your model $payStartDate = $payrollSetting->start_date; // Calculate the number of days between the start date and the current date $daysDifference = floor((strtotime($currentDate) - strtotime($payStartDate)) / (60 * 60 * 24)); // Calculate the pay period (assuming weekly) $payPeriod = floor($daysDifference / 7) + 1; // Calculate the start and end dates of the current pay period $currentPayStartDate = date('Y-m-d', strtotime($payStartDate . ' +' . (($payPeriod - 1) * 7) . ' days')); $currentPayEndDate = date('Y-m-d', strtotime($currentPayStartDate . ' +6 days')); // Get the last pay period's start date $lastPayStartDate = date('Y-m-d', strtotime($currentPayStartDate . ' -7 days')); // Calculate the end date of the last pay period $lastPayEndDate = date('Y-m-d', strtotime($lastPayStartDate . ' +6 days')); } @endphp
{{ $message }}
Current Pay Period: {{ date('M d, Y',strtotime($currentPayStartDate)) }} to {{ date('M d, Y',strtotime($currentPayEndDate)) }}
@elseif (request()->get('filter') == 'last_week')Last Pay Period: {{ date('M d, Y',strtotime($lastPayStartDate)) }} to {{ date('M d, Y',strtotime($lastPayEndDate)) }}
@endif| Employee | Role | {{--Regular Hours | --}}Hours | Break | OT | Wage | OT | Total | Action |
|---|---|---|---|---|---|---|---|---|---|
| {{ $staff->roles->whereNotIn('name', 'BranchStaffMember')->first()->display_name ?? '-' }} | {{--40 | --}}@if( $staff->clock ) @php $total += collect($staff->clock)->sum('time'); $hours = floor(collect($staff->clock)->sum('time') / 3600); $mins = floor(collect($staff->clock)->sum('time') / 60 % 60); // echo sprintf('%02d:%02d', $hours, $mins); echo timeDiffInHoursAndMins($hours, $mins); @endphp @else 0 @endif | {{ $staff->break_time ?? '-' }} | @php /* Daily OT // $working_hours = 8; // Dynamically added $regular_hours = $working_hours * 60 * 60; $overtime_clocked = 0; foreach( $staff->clock as $date => $clock ) { if( $clock['time'] > $regular_hours ) { $overtime_clocked += $clock['time'] - $regular_hours; } } $hours = floor($overtime_clocked / 3600); $mins = floor($overtime_clocked / 60 % 60); echo timeDiffInHoursAndMins($hours, $mins); */ // Weekly OT $overtime_clocked = $staff->otGrandTotal ?? 0; $hours = floor($overtime_clocked / 3600); $mins = floor($overtime_clocked / 60 % 60); echo timeDiffInHoursAndMins($hours, $mins); @endphp | ${{ !empty($staff->payment_type_hourly) ? number_format($staff->payment_type_hourly, 2) : '0.00' }} | @if( isset($staff->payment_type_hourly) && $staff->payment_type_hourly > 0 ) @if( $overtime_clocked ) @php $per_hour = $staff->payment_type_hourly; $hours = floor($overtime_clocked / 3600); $mins = floor($overtime_clocked / 60 % 60); // Calculate the total amount (rate = 1.5 is for overtime pay) $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 $ {{ '0' }} @endif @else {{ 'N/A' }} @endif | @if( isset($staff->payment_type_hourly) && $staff->payment_type_hourly > 0 ) @if( $staff->clock ) @php $per_hour = $staff->payment_type_hourly; $hours = floor( ( collect($staff->clock)->sum('time') - $overtime_clocked ) / 3600); $mins = floor( ( collect($staff->clock)->sum('time') - $overtime_clocked ) / 60 % 60); $ohours = floor( $overtime_clocked / 3600); $omins = floor( $overtime_clocked / 60 % 60); // Calculate the total amount + OT $total_amount = round($hours * $per_hour + $mins * ($per_hour / 60), 2) + round($ohours * $per_hour + $omins * ($per_hour / 60), 2) * 1.5; // rate = 1.5 for OT(Over time) // $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 $ {{ '0' }} @endif @else {{ 'N/A' }} @endif |
|
|
| Payroll Total | @if( $total > 0 ) @php $hours = floor($total / 3600); $mins = floor($total / 60 % 60); // echo sprintf('%02d:%02d', $hours, $mins); echo timeDiffInHoursAndMins($hours, $mins); @endphp @else 0 @endif |