@extends('layouts.head_office_app') @section('title', 'Tasks') @section('content') @php $has_access_to_all_tasks = $profile->super_access == 1 || ($profile->is_access_tasks == 1 && $profile->task_access_type && (in_array('all_tasks', $profile->task_access_type) || in_array('sites_tasks', $profile->task_access_type) || in_array('certain_users_tasks', $profile->task_access_type))); $has_own_tasks_access = $profile->super_access == 1 || ($profile->is_access_tasks == 1 && (empty($profile->task_access_type) || in_array('all_tasks', $profile->task_access_type) || in_array('own_tasks', $profile->task_access_type))); @endphp
Filter Tasks
APPLIED FILTER
×
30 Days

Tasks

Send Task
{{-- ALL TASKS TAB PANEL --}} @if ($has_access_to_all_tasks && isset($all_tasks))
{{-- Changed ID to be unique --}}
@forelse ((($all_tasks ?? collect())->take(10)) as $task) {{-- Initial slice for lazy load --}} @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 ($profile->super_access == 1 && $task->shared_with == 'user') @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], key('task-status-' . $task->id))
@if ($task->task_case && ($profile->super_access == 1 || $profile->is_access_case_manager == 1)) View Case @endif
@empty

No tasks found for this view.

@endforelse
@endif @if ($has_own_tasks_access) {{-- SENT BY ME TAB PANEL --}}
{{-- Changed ID to be unique --}}
{{-- Changed class to be unique --}} @forelse ((collect($user_tasks ?? [])->take(10)) as $main_task) {{-- Initial slice for lazy load --}} @php // Check if there's an extended due date (dead_line_date or task_over_due_date) $extendedDueDate = null; if ($main_task->dead_line_date) { $extendedDueDate = $main_task->dead_line_date; } elseif ($main_task->task_over_due_date) { $extendedDueDate = $main_task->task_over_due_date; } // Use extended due date if available, otherwise use the original due date $effectiveDueDate = $extendedDueDate ? $extendedDueDate : $main_task->due_date; // Calculate if overdue based on the effective due date $isOverdue = $effectiveDueDate && \Carbon\Carbon::parse($effectiveDueDate)->isPast() && $main_task->status !== 'completed'; @endphp
@if ($main_task->shared_with == 'user') @endif Task #{{ $main_task->id }}
@if ($main_task->shared_with == 'user') User Task @elseif ($main_task->shared_with == 'location') Site Task @elseif(isset($main_task->case_id)) Case Task @endif
{{ $main_task->title ?? '[Task Name goes here]' }}
{{ $main_task->priority ?? 'No Priority' }} @if ($isOverdue) Overdue @endif
Created by: {{ optional(optional($main_task->created_by)->user)->name ?? 'Default Task' }}
Created at: {{ \Carbon\Carbon::parse($main_task->created_at)->format('d M Y (D) h:i a') }}
Last Updated {{ $main_task->updated_at->diffForHumans() }}
Due Date: {{ $effectiveDueDate ? \Carbon\Carbon::parse($effectiveDueDate)->format('d M Y (D) h:i a') : 'No Due Date' }}
@if (optional($main_task->ho_allocations)->count() > 0)
Assigned To: {{ optional($main_task->ho_allocations)->pluck('head_office_user.user.name')->filter()->implode(', ') ?? '' }}
@endif @if (optional($main_task->loc_allocations)->count() > 0)
Assigned To: {{ optional($main_task->loc_allocations)->load('head_office_location.location')->pluck('head_office_location.location.trading_name')->filter()->implode(', ') ?? '' }}
@endif @if (isset($main_task->task_case) && isset($main_task) && isset($main_task->task_case) && isset($main_task->task_case->location_name))
Site Involved: {{ optional($main_task->task_case)->location_name ?? 'Unknown Site' }}
@endif

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

No tasks found for this view.

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

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

No tasks found for this view.

@endforelse
@endif
@endsection @section('scripts') {{-- --}} @endsection