@php
$attendanceArray = [];
foreach ($totalRequestCheck as $totalRequest) {
$dt = \Carbon\Carbon::parse($totalRequest->date);
$attendanceArray[$totalRequest->user_id][$dt->format('Y-m-d')] = $totalRequest;
}
$attendanceArrays = [];
foreach ($totalRequestCheck as $totalRequests) {
if ($totalRequests->status == 'pending') {
$dts = \Carbon\Carbon::parse($totalRequests->date);
$attendanceArrays[$totalRequests->user_id][$dts->format('Y-m-d')] = $totalRequests;
}
}
@endphp
@forelse ($dateWiseData as $key => $dateData)
@php
$currentDate = \Carbon\Carbon::parse($key);
$today = \Carbon\Carbon::now()->copy();
$endDateofMonth = $currentDate->copy()->endOfMonth();
$startDateofAdjustment = $today->copy()->subDays($lastDays);
$startDateOfMonth = $currentDate->copy()->startOfMonth();
// For times_adjustment_allowed == '3', we need current month's start and end dates
$currentMonthStart = $today->copy()->startOfMonth();
$currentMonthEnd = $today->copy()->endOfMonth();
// Calculate before_day_of_month date safely
$beforeDayOfMonth = null;
if (isset($attendanceSettings->before_day_of_month) && $attendanceSettings->before_day_of_month) {
try {
$beforeDayOfMonth = $today->copy()->startOfMonth()->setDay($attendanceSettings->before_day_of_month);
} catch (\Exception $e) {
// If day doesn't exist in month (e.g., 31 in February), use last day of month
$beforeDayOfMonth = $today->copy()->endOfMonth();
}
}
$requestForDate = $attendanceArray[$userId][$key] ?? null;
// Determine if a request exists and its status
$matchingRequest = !is_null($requestForDate);
$requestStatus = $requestForDate->status ?? null;
@endphp
@if (isset($dateData['attendance']) && ($dateData['attendance'] == true) && $dateData['leave'] != true)
{{ $currentDate->translatedFormat(company()->date_format) }}
|
@lang('modules.attendance.present')
@if ($attendanceSettings?->adjust_attendance_logs == 'all_logs' && $attendanceSettings?->adjustment_allowed == '1')
@if ($attendanceSettings?->times_adjustment_allowed == '1')
@if ($currentDate->between($startDateofAdjustment, $today) && ($currentDate->isSameDay($employeeJoiningDate) || $currentDate->greaterThan($employeeJoiningDate)))
@if ($matchingRequest)
@if ($requestStatus == 'pending')
@lang('clan.attendance.requestPending')
@endif
@else
@lang('clan.attendance.requestRegularise')
@endif
@endif
@elseif ($attendanceSettings?->times_adjustment_allowed == '2')
@if ($currentDate->between($checkStartDate, $checkEndDate) && $conditionWiseCount < $attendanceSettings?->adjustment_total_times && ($currentDate->isSameDay($employeeJoiningDate) || $currentDate->greaterThan($employeeJoiningDate)))
@if ($matchingRequest)
@if ($requestStatus == 'pending')
@lang('clan.attendance.requestPending')
@endif
@else
@lang('clan.attendance.requestRegularise')
@endif
@endif
@elseif ($attendanceSettings?->times_adjustment_allowed == '3' && $beforeDayOfMonth)
@if ($currentDate->between($currentMonthStart, $beforeDayOfMonth) && $today->between($currentMonthStart, $currentMonthEnd) && ($currentDate->isSameDay($employeeJoiningDate) || $currentDate->greaterThan($employeeJoiningDate)))
@if ($matchingRequest)
@if ($requestStatus == 'pending')
@lang('clan.attendance.requestPending')
@endif
@else
@lang('clan.attendance.requestRegularise')
@endif
@endif
@else
@if ($matchingRequest)
@if ($requestStatus == 'pending')
@lang('clan.attendance.requestPending')
@endif
@else
@lang('clan.attendance.requestRegularise')
@endif
@endif
@endif
|
@foreach ($dateData['attendance'] as $attendance)
|
{{ $attendance->clock_in_time->timezone(company()->timezone)->translatedFormat(company()->time_format) }}
@if ($attendance->late == 'yes')
@lang('modules.attendance.late')
@endif
@if ($attendance->half_day == 'yes')
@lang('modules.attendance.halfDay')
@if($attendance->half_day_type == 'first_half')
( @lang('modules.leaves.1stHalf') )
@elseif ($attendance->half_day_type == 'second_half')
( @lang('modules.leaves.2ndHalf') )
@else
@endif
@endif
@if ($attendance->work_from_type != '')
@if ($attendance->work_from_type == 'other')
{{ $attendance->location }} ({{$attendance->working_from}})
@else
{{ $attendance->location }} ({{$attendance->work_from_type}})
@endif
@endif
|
@if (!is_null($attendance->clock_out_time))
{{ $attendance->clock_out_time->timezone(company()->timezone)->translatedFormat(company()->time_format) }}
@if($attendance->auto_clock_out)
@lang('modules.attendance.autoClockOut')
@endif
@else - @endif
|
@endforeach
|
{{ $attendance->totalTime($attendance->clock_in_time, $attendance->clock_in_time, $attendance->user_id) }}
|
@lang('app.details')
|
@else
{{ $currentDate->translatedFormat(company()->date_format) }}
{{ $currentDate->translatedFormat('l') }}
|
@if (isset($dateData['day_off']) && ($dateData['day_off'] == true))
@elseif (!$dateData['holiday'] && !$dateData['leave'])
@if ($attendanceSettings?->adjust_attendance_logs != 'not_allowed' && $attendanceSettings?->adjustment_allowed == '1')
@if ($attendanceSettings?->times_adjustment_allowed == '1')
@if ($currentDate->between($startDateofAdjustment, $today) && ($currentDate->isSameDay($employeeJoiningDate) || $currentDate->greaterThan($employeeJoiningDate)))
@if ($matchingRequest)
@if ($requestStatus == 'pending')
@lang('clan.attendance.requestPending')
@endif
@else
@lang('clan.attendance.requestRegularise')
@endif
@endif
@elseif ($attendanceSettings?->times_adjustment_allowed == '2')
@if ($currentDate->between($checkStartDate, $checkEndDate) && $conditionWiseCount < $attendanceSettings?->adjustment_total_times && ($currentDate->isSameDay($employeeJoiningDate) || $currentDate->greaterThan($employeeJoiningDate)))
@if ($matchingRequest)
@if ($requestStatus == 'pending')
@lang('clan.attendance.requestPending')
@endif
@else
@lang('clan.attendance.requestRegularise')
@endif
@endif
@elseif ($attendanceSettings?->times_adjustment_allowed == '3' && $beforeDayOfMonth)
@if ($currentDate->between($currentMonthStart, $beforeDayOfMonth) && $today->between($currentMonthStart, $currentMonthEnd) && ($currentDate->isSameDay($employeeJoiningDate) || $currentDate->greaterThan($employeeJoiningDate)))
@if ($matchingRequest)
@if ($requestStatus == 'pending')
@lang('clan.attendance.requestPending')
@endif
@else
@lang('clan.attendance.requestRegularise')
@endif
@endif
@endif
@endif
@elseif($dateData['leave'])
@if ($dateData['leave']['duration'] == 'half day')
@else
@endif
@else
@endif
|
@if (isset($dateData['attendance']) && ($dateData['attendance'] == true))
@foreach ($dateData['attendance'] as $attendance)
|
{{ $attendance->clock_in_time->timezone(company()->timezone)->translatedFormat(company()->time_format) }}
@if ($attendance->late == 'yes')
@lang('modules.attendance.late')
@endif
@if ($attendance->half_day == 'yes')
@lang('modules.attendance.halfDay')
@endif
@if ($attendance->work_from_type != '')
@if ($attendance->work_from_type == 'other')
{{ $attendance->location }} ({{$attendance->working_from}})
@else
{{ $attendance->location }} ({{$attendance->work_from_type}})
@endif
@endif
|
@if (!is_null($attendance->clock_out_time))
{{ $attendance->clock_out_time->timezone(company()->timezone)->translatedFormat(company()->time_format) }}
@else - @endif
|
@endforeach
|
{{ $attendance->totalTime($attendance->clock_in_time, $attendance->clock_in_time, $attendance->user_id) }} |
@lang('app.details')
|
@else
|
- |
- |
@endif
@endif
@empty
|
|
@endforelse