@foreach($tasks as $task) @php // Check if there's an extended due date (dead_line_date or task_over_due_date) $extendedDueDate = null; if ($task->dead_line_date) { $extendedDueDate = $task->dead_line_date; } elseif ($task->task_over_due_date) { $extendedDueDate = $task->task_over_due_date; } // Use extended due date if available, otherwise use the original due date $effectiveDueDate = $extendedDueDate ? $extendedDueDate : $task->due_date; // Calculate if overdue based on the effective due date $isOverdue = $effectiveDueDate && \Carbon\Carbon::parse($effectiveDueDate)->isPast() && $task->status !== 'completed'; @endphp
@if ($tab === 'all') @if ($profile->super_access == 1 && $task->shared_with == 'user') @endif @else @if ( ($profile->super_access == 1 && $task->shared_with == 'user') || ( $profile->super_access != 1 && $profile->is_access_tasks == 1 && $task->shared_with == 'user' && ( $task->ho_allocations->where('head_office_user_id', $head_office_user->id)->first() != null || $task->head_office_user_id == $head_office_user->id ) ) ) @endif @endif Task #{{ $task->id }}
@if ($task->shared_with == 'user') User Task @elseif ($task->shared_with == 'location') Site Task @elseif(isset($task->case_id)) Case Task @endif
{{ $task->title ?? '[Task Name goes here]' }}
{{ $task->priority ?? 'No Priority' }} @if ($isOverdue) Overdue @endif
@if (isset($task->created_by) && isset($task->created_by->user->logo))
Created by: {{ optional(optional($task->created_by)->user)->name ?? 'Default Task' }}
@endif
Created at: {{ \Carbon\Carbon::parse($task->created_at)->format('d M Y (D) h:i a') }}
Last Updated {{ $task->updated_at->diffForHumans() }}
Due Date: {{ $effectiveDueDate ? \Carbon\Carbon::parse($effectiveDueDate)->format('d M Y (D) h:i a') : 'No Due Date' }}
@if ($task->ho_allocations->count() > 0)
Assigned To: {{ optional($task->ho_allocations)->pluck('head_office_user.user.name')->filter()->implode(', ') ?? '' }}
@endif @if ($task->loc_allocations->count() > 0)
Assigned To: {{ optional($task->loc_allocations)->load('head_office_location.location')->pluck('head_office_location.location.trading_name')->filter()->implode(', ') ?? '' }}
@endif @if (isset($task->task_case) && $task->task_case->location_name != null)
Site Involved: {{ optional($task->task_case)->location_name ?? 'Unknown Site' }}
@endif

{!! $task->description ?? 'No Description' !!}
@livewire('task-status', ['task' => $task->id])
@if ($task->task_case && ($profile->super_access == 1 || $profile->is_access_case_manager == 1)) View Case @endif
@endforeach