@if($staff->jobTitle && strtolower($staff->jobTitle->slug) === 'tester' && isset($testerSlotsData) && $testerSlotsData['slots']->count() > 0) @php $slots = $testerSlotsData['slots']; $selectedSlots = $testerSlotsData['selectedSlots']; $selectedSlotIds = $selectedSlots->pluck('id')->toArray(); $testerAssignedSlots = $selectedSlots->filter(function ($slot) use ($staff) { return collect($slot['staff_slots'] ?? [])->contains(function ($staffSlot) use ($staff) { return (int) ($staffSlot['staff_id'] ?? 0) === (int) $staff->id; }); })->values(); $daysOfWeek = ['Saturday', 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday']; $morningSlots = $slots->filter(function($slot) { $slotTime = strtotime($slot['slot_start']); $hour = (int)date('H', $slotTime); $minute = (int)date('i', $slotTime); $totalMinutes = $hour * 60 + $minute; return $totalMinutes < (16 * 60 + 30); // Before 16:30 })->values(); $nightSlots = $slots->filter(function($slot) { $slotTime = strtotime($slot['slot_start']); $hour = (int)date('H', $slotTime); $minute = (int)date('i', $slotTime); $totalMinutes = $hour * 60 + $minute; return $totalMinutes >= (17 * 60 + 30); })->values(); @endphp
Tester Schedule
{{ $testerAssignedSlots->count() }} assigned slots
@if($testerAssignedSlots->count() > 0)
@foreach($daysOfWeek as $day) @php $daySlots = $testerAssignedSlots ->filter(fn ($slot) => strtolower($slot['slot_day']) === strtolower($day)) ->sortBy('slot_start') ->values(); @endphp
{{ $day }}
@forelse($daySlots as $slot) @php $staffSlot = collect($slot['staff_slots'] ?? [])->first(function ($staffSlot) use ($staff) { return (int) ($staffSlot['staff_id'] ?? 0) === (int) $staff->id; }); $sources = $staffSlot['department_added_by'] ?? []; if (is_string($sources)) { $decoded = json_decode($sources, true); $sources = is_array($decoded) ? $decoded : array_filter(array_map('trim', explode(',', $sources))); } $sources = is_array($sources) ? $sources : []; $sourceLabel = collect($sources)->map(fn ($source) => ucfirst($source))->implode(' + '); @endphp
{{ date('g:i A', strtotime($slot['slot_start'])) }} - {{ date('g:i A', strtotime($slot['slot_end'])) }} {{ ucfirst($slot['timing_type'] ?? 'shift') }}{{ $sourceLabel ? ' | '.$sourceLabel : '' }}
@empty
No slots
@endforelse
@endforeach
@else
No scheduled slots assigned to this tester.
@endif
{{-- Hint Section --}}
HR Slot
Schedule Slot
Both HR + Schedule
{{-- Morning Shift Table --}} @if($morningSlots->count() > 0) @php $groupedMorning = []; foreach ($morningSlots as $slot) { $timeRange = date('g:i A', strtotime($slot['slot_start'])) . ' - ' . date('g:i A', strtotime($slot['slot_end'])); if (!isset($groupedMorning[$timeRange])) { $groupedMorning[$timeRange] = []; } $groupedMorning[$timeRange][] = $slot; } $selectedAdminIdMorning = '0'; if (isset($testerOldAdmins)) { $matchingAssignmentMorning = $testerOldAdmins->first(function($assignment) { return $assignment->shift === 'morning'; }); if ($matchingAssignmentMorning) { $selectedAdminIdMorning = $matchingAssignmentMorning->admin_id; } } @endphp
Morning Shift
@foreach($daysOfWeek as $day) @endforeach @foreach($groupedMorning as $timeRange => $timeSlots) @foreach($daysOfWeek as $day) @php $slot = collect($timeSlots)->first(function($s) use ($day) { return strtolower($s['slot_day']) === strtolower($day); }); $isChecked = false; $borderClass = ''; if ($slot) { $selectedSlot = $selectedSlots->first(function($s) use ($slot) { return $s['id'] == $slot['id']; }); if ($selectedSlot && count($selectedSlot['staff_slots']) > 0) { $staffSlot = collect($selectedSlot['staff_slots'])->first(function($ss) use ($slot, $staff) { return $ss['slot_id'] == $slot['id'] && $ss['staff_id'] == $staff->id; }); if ($staffSlot) { $deptSources = $staffSlot['department_added_by']; if (is_string($deptSources)) { $decoded = json_decode($deptSources, true); $deptSources = is_array($decoded) ? $decoded : array_filter(array_map('trim', explode(',', $deptSources))); } $deptSources = is_array($deptSources) ? $deptSources : []; $fromHR = in_array('hr', $deptSources); $fromSchedule = in_array('schedule', $deptSources); if ($fromHR && $fromSchedule) { $borderClass = 'border-both'; } elseif ($fromHR) { $borderClass = 'border-hr'; } elseif ($fromSchedule) { $borderClass = 'border-schedule'; } $isChecked = true; } } else { $isChecked = in_array($slot['id'], $selectedSlotIds); } } @endphp @endforeach @endforeach
Time Slot{{ $day }}
{{ $timeRange }} @if($slot)
@endif
@else
Morning Shift
@foreach($daysOfWeek as $day) @endforeach
Time Slot{{ $day }}
No morning slots found
@endif @if($nightSlots->count() > 0) @php $groupedNight = []; foreach ($nightSlots as $slot) { $timeRange = date('g:i A', strtotime($slot['slot_start'])) . ' - ' . date('g:i A', strtotime($slot['slot_end'])); if (!isset($groupedNight[$timeRange])) { $groupedNight[$timeRange] = []; } $groupedNight[$timeRange][] = $slot; } // Get selected admin for night shift $selectedAdminIdNight = '0'; if (isset($testerOldAdmins)) { $matchingAssignmentNight = $testerOldAdmins->first(function($assignment) { return $assignment->shift === 'night'; }); if ($matchingAssignmentNight) { $selectedAdminIdNight = $matchingAssignmentNight->admin_id; } } @endphp
Night Shift
@foreach($daysOfWeek as $day) @endforeach @foreach($groupedNight as $timeRange => $timeSlots) @foreach($daysOfWeek as $day) @php $slot = collect($timeSlots)->first(function($s) use ($day) { return strtolower($s['slot_day']) === strtolower($day); }); $isChecked = false; $borderClass = ''; if ($slot) { $selectedSlot = $selectedSlots->first(function($s) use ($slot) { return $s['id'] == $slot['id']; }); if ($selectedSlot && count($selectedSlot['staff_slots']) > 0) { $staffSlot = collect($selectedSlot['staff_slots'])->first(function($ss) use ($slot, $staff) { return $ss['slot_id'] == $slot['id'] && $ss['staff_id'] == $staff->id; }); if ($staffSlot) { $deptSources = $staffSlot['department_added_by']; if (is_string($deptSources)) { $decoded = json_decode($deptSources, true); $deptSources = is_array($decoded) ? $decoded : array_filter(array_map('trim', explode(',', $deptSources))); } $deptSources = is_array($deptSources) ? $deptSources : []; $fromHR = in_array('hr', $deptSources); $fromSchedule = in_array('schedule', $deptSources); if ($fromHR && $fromSchedule) { $borderClass = 'border-both'; } elseif ($fromHR) { $borderClass = 'border-hr'; } elseif ($fromSchedule) { $borderClass = 'border-schedule'; } $isChecked = true; } } else { $isChecked = in_array($slot['id'], $selectedSlotIds); } } @endphp @endforeach @endforeach
Time Slot{{ $day }}
{{ $timeRange }} @if($slot)
@endif
@else
Night Shift
@foreach($daysOfWeek as $day) @endforeach
Time Slot{{ $day }}
No night slots found
@endif
@else
No available slots

No slots assigned to this Tester.

@endif