@extends('layouts.app') @php $pageTitle = 'ADMS Dashboard'; $pageHeading = 'Operational Dashboard'; $pageDescription = 'Monitoring device, transaksi, command queue, dan integrasi user dalam satu tampilan.'; $sessionRole = strtolower((string) (($currentUser['role'] ?? null) ?: (!empty($currentUser['is_superuser']) ? 'admin' : 'viewer'))); @endphp @section('content') @php $expiredCode = \App\Services\Device\CommandQueue::RETURN_EXPIRED; @endphp @if (($internetPackagesDue ?? collect())->isNotEmpty())

{{ $internetPackagesDue->count() }} paket data perlu perhatian

Buka Device Management
@foreach ($internetPackagesDue as $internetDevice) @php($daysLeft = now()->startOfDay()->diffInDays(\Illuminate\Support\Carbon::parse($internetDevice->internet_package_expires_at), false))
{{ $internetDevice->alias ?: $internetDevice->sn }} {{ $internetDevice->sim_phone_number ?: '-' }}{{ $internetDevice->sim_provider ? ' - '.$internetDevice->sim_provider : '' }} Berakhir: {{ $internetDevice->internet_package_expires_at }} ({{ $daysLeft < 0 ? 'sudah habis' : 'sisa '.$daysLeft.' hari' }})
@endforeach
@endif @if (($offlineDevices ?? collect())->isNotEmpty())

{{ $offlineDevices->count() }} perangkat sedang offline

Buka Device Management
@foreach ($offlineDevices as $offlineDevice)
{{ $offlineDevice->alias ?: $offlineDevice->sn }} SN: {{ $offlineDevice->sn }} · IP: {{ $offlineDevice->ip_address ?: '-' }} Aktivitas terakhir: {{ $offlineDevice->last_activity ?: 'Belum pernah terhubung' }} {{ $offlineDevice->presence_meta }}
@endforeach
@endif
Devices {{ number_format($summary['devices']) }}
Pending Devices {{ number_format($summary['pending_devices']) }}
Waiting First Sync {{ number_format($summary['waiting_first_sync']) }}
Offline Devices {{ number_format($summary['offline_devices'] ?? 0) }}
Paket Data ≤7 Hari {{ number_format($summary['internet_packages_due'] ?? 0) }}
Employees {{ number_format($summary['employees']) }}
Transactions {{ number_format($summary['transactions']) }}
Pending Commands {{ number_format($summary['pending_commands']) }}
@if (in_array($sessionRole, ['admin', 'operator', 'viewer'], true)) Device Bugs {{ number_format($summary['device_errors_open'] ?? 0) }} @endif
Active Users {{ number_format($summary['active_users']) }}
Polling Only {{ number_format($deviceActivitySummary['polling'] ?? 0) }}
Data Sync Active {{ number_format($deviceActivitySummary['data_sync'] ?? 0) }}

Latest Transactions

{{ $latestTransactions->count() }} latest
@forelse ($latestTransactions as $item) @empty @endforelse
Emp Code Punch Time State Terminal Upload Time
{{ $item->emp_code }} {{ $item->punch_time }} {{ $transactionStateLabels[(int) $item->punch_state] ?? ('UNKNOWN (' . $item->punch_state . ')') }} {{ $item->terminal_sn }} {{ $item->upload_time }}
Belum ada transaksi.

Latest Device Commands

{{ $latestCommands->count() }} latest
@forelse ($latestCommands as $item) @empty @endforelse
Terminal Content Commit Return
{{ $item->terminal_alias ?: $item->terminal_sn ?: $item->terminal_id }}
@if (($item->terminal_alias ?? null) && ($item->terminal_sn ?? null))
{{ $item->terminal_sn }}
@endif
{{ \Illuminate\Support\Str::limit($item->content, 70) }} {{ $item->commit_time }} @if (is_null($item->return_time)) Pending @elseif ((int) $item->return_value === \App\Services\Device\CommandQueue::RETURN_ACK_OPERLOG) Success via OPERLOG @elseif ((int) $item->return_value === 0) Success @elseif ((int) $item->return_value === $expiredCode) Expired @else Error ({{ $item->return_value }}) @endif
Belum ada command device.

Active Devices Snapshot

{{ $devices->count() }} devices
@forelse ($devices as $device) @empty @endforelse
Alias Serial Number IP State User Qty Transaction Qty Last Poll Last Data Sync Last Activity
{{ $device->alias }}
@if ((int) $device->status !== 1 && $device->create_time && \Illuminate\Support\Carbon::parse($device->create_time)->isToday())
New Device
@endif
{{ $device->sn }} {{ $device->ip_address }}
@if ((int) $device->status !== 1) Ping Blocked @elseif (empty($device->first_sync_at)) Waiting First Sync @else {{ $device->presence_label }}
@php($activityType = $device->presence_activity_type ?? null) @php($activityClass = $activityType === 'polling' ? 'dashboard-status--info' : ($activityType === 'data_sync' ? 'dashboard-status--success' : 'dashboard-status--pending')) {{ $device->presence_activity_label }}
@endif
@if ((int) $device->status !== 1) Pending approval, belum boleh sync. @elseif (empty($device->first_sync_at)) Approved, tapi feedback pertama dari mesin belum masuk. @else {{ $device->presence_meta }} @endif
{{ $device->user_count }}
DB: {{ $device->db_user_count ?? 0 }}
{{ $device->transaction_count }}
DB: {{ $device->db_transaction_count ?? 0 }}
{{ $device->push_time ?: '-' }}
@if (! empty($device->push_time)) {{ \Illuminate\Support\Carbon::parse($device->push_time)->diffForHumans() }} @else Belum ada poll @endif
{{ $device->upload_time ?: '-' }}
@if (! empty($device->upload_time)) {{ \Illuminate\Support\Carbon::parse($device->upload_time)->diffForHumans() }} @else Belum ada sync data @endif
{{ $device->last_activity ?: '-' }}
{{ $device->presence_meta ?? 'Belum ada heartbeat' }}
First sync: {{ $device->first_sync_at ?: '-' }}
Belum ada device yang tersimpan.
@endsection