@php $recentTasks = \Illuminate\Support\Facades\DB::table('schedule_tasks') ->leftJoin('users', 'schedule_tasks.user_id', '=', 'users.user_id') ->select([ 'schedule_tasks.id', 'schedule_tasks.title', 'schedule_tasks.status', 'schedule_tasks.config', 'schedule_tasks.user_id', 'schedule_tasks.created_at', 'schedule_tasks.updated_at', \Illuminate\Support\Facades\DB::raw("COALESCE(users.name, IF(schedule_tasks.user_id = 0, 'System S', 'Unknown')) as user_name"), ]) ->orderByDesc('schedule_tasks.id') ->limit(20) ->get() ->map(function ($task) { $config = json_decode($task->config, true) ?: []; $duration = ''; if ($task->status == 2 && $task->created_at && $task->updated_at) { $start = strtotime($task->created_at); $end = strtotime($task->updated_at); $diff = $end - $start; $duration = $diff >= 60 ? intdiv($diff, 60) . 'm ' . ($diff % 60) . 's' : $diff . 's'; } $file = ''; if (isset($config['fileName'])) { $file = basename($config['fileName']); } elseif (isset($config['processId'])) { $file = 'Process: ' . $config['processId']; } $total = isset($config['fileName']) ? '' : ''; $percent = $task->status == 2 ? 100 : ($task->status == 1 ? 50 : ($task->status == 0 ? 0 : 100)); return (object)[ 'id' => $task->id, 'title' => $task->title, 'status' => (int)$task->status, 'user' => $task->user_name, 'file' => $file, 'created_at' => $task->created_at, 'duration' => $duration, 'percent' => $percent, ]; }); $taskCount = $recentTasks->count(); $processingCount = $recentTasks->where('status', 1)->count(); @endphp {{-- Badges bar — centered, looks like old Central header icons --}}
{{ $task->title }} [{{ $task->user }}]
@if($task->file) @endifStarted at {{ $task->created_at }}
@if($task->duration)Duration: {{ $task->duration }}
@endifNo recent tasks
@endforelseNotifications
@foreach($recentTasks->where('status', 2)->take(10) as $task){{ $task->created_at }}
{{ str_replace('UPDATE PRODUCT STOCKS & PRICES', 'Product stocks & prices updated.', str_replace('IMPORT SUPPLIER PARTS DATA', 'Supplier parts successfully imported.', $task->title)) }} Scheduled by user {{ $task->user }}
No notifications
@endif