{{-- 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;
}
// Get selected admin for morning shift
$selectedAdminIdMorning = '0';
if (isset($teacherOldAdmins)) {
$matchingAssignmentMorning = $teacherOldAdmins->first(function($assignment) use ($trackTypeId) {
return $assignment->track_type_id == $trackTypeId && $assignment->shift === 'morning';
});
if ($matchingAssignmentMorning) {
$selectedAdminIdMorning = $matchingAssignmentMorning->admin_id;
}
}
@endphp
Morning Shift
| Time Slot |
@foreach($daysOfWeek as $day)
{{ $day }} |
@endforeach
@foreach($groupedMorning as $timeRange => $timeSlots)
| {{ $timeRange }} |
@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, $trackTypeId) {
return $ss['slot_id'] == $slot['id'] && $ss['track_type_id'] == $trackTypeId;
});
if ($staffSlot) {
$deptSources = is_array($staffSlot['department_added_by']) ? $staffSlot['department_added_by'] : [];
$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;
}
}
}
@endphp
@if($slot)
@endif
|
@endforeach
@endforeach
@endif
{{-- Night Shift Table --}}
@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($teacherOldAdmins)) {
$matchingAssignmentNight = $teacherOldAdmins->first(function($assignment) use ($trackTypeId) {
return $assignment->track_type_id == $trackTypeId && $assignment->shift === 'night';
});
if ($matchingAssignmentNight) {
$selectedAdminIdNight = $matchingAssignmentNight->admin_id;
}
}
@endphp
Night Shift
| Time Slot |
@foreach($daysOfWeek as $day)
{{ $day }} |
@endforeach
@foreach($groupedNight as $timeRange => $timeSlots)
| {{ $timeRange }} |
@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, $trackTypeId) {
return $ss['slot_id'] == $slot['id'] && $ss['track_type_id'] == $trackTypeId;
});
if ($staffSlot) {
$deptSources = is_array($staffSlot['department_added_by']) ? $staffSlot['department_added_by'] : [];
$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;
}
}
}
@endphp
@if($slot)
@endif
|
@endforeach
@endforeach
@endif