@extends('layouts.app') @section('title', 'View Connection Log - ISP ERP System') @section('page-title', 'Connection Log Details') @section('content')

Connection Log Details

View connection log information

Total Connected

{{ $totalConnected }}

Total Disconnected

{{ $totalDisconnected }}

Last Connected

@if($lastConnected) {{ $lastConnected->created_at->format('M d, Y') }}
{{ $lastConnected->created_at->format('H:i:s') }} @else N/A @endif

Last Disconnected

@if($lastDisconnected) {{ $lastDisconnected->created_at->format('M d, Y') }}
{{ $lastDisconnected->created_at->format('H:i:s') }} @else N/A @endif

Log Information

Username:

{{ $userConnectionLog->username }}

Action:

@if($userConnectionLog->action == 'connect') Connect @else Disconnect @endif

Status:

@php $status = 'N/A'; $statusBadge = 'secondary'; if ($userConnectionLog->action == 'connect') { if (isset($isStillActive) && $isStillActive && isset($isActiveInAnyServer) && $isActiveInAnyServer) { $status = 'Active'; $statusBadge = 'success'; } elseif (isset($isStillActive) && !$isStillActive) { $status = 'Disconnected'; $statusBadge = 'danger'; } else { $status = 'Disconnected'; $statusBadge = 'warning'; } } else { $status = 'Disconnected'; $statusBadge = 'warning'; } @endphp @if($status != 'N/A') @if($status == 'Active') @else @endif {{ $status }} @if($status == 'Active' && isset($isActiveInAnyServer) && $isActiveInAnyServer) (Active in at least one MikroTik server) @elseif($status == 'Disconnected' && $statusBadge == 'danger') (Was connected but now disconnected) @endif @else {{ $status }} @endif

MikroTik Server:

@if($userConnectionLog->mikrotikServer) {{ $userConnectionLog->mikrotikServer->name }} ({{ $userConnectionLog->mikrotikServer->host }}) @else N/A @endif

Client:

@if($userConnectionLog->client) {{ $userConnectionLog->client->username }} - {{ $userConnectionLog->client->name ?? 'N/A' }} @else N/A @endif

IP Address:

@if($userConnectionLog->ip_address) {{ $userConnectionLog->ip_address }} @else N/A @endif

MAC Address:

@if($userConnectionLog->mac_address) {{ $userConnectionLog->mac_address }} @else N/A @endif

Session ID:

@if($userConnectionLog->session_id) {{ $userConnectionLog->session_id }} @else N/A @endif

Interface:

@if($userConnectionLog->interface) {{ $userConnectionLog->interface }} @else N/A @endif

Profile:

@if($userConnectionLog->profile) {{ $userConnectionLog->profile }} @else N/A @endif

Reason:

@if($userConnectionLog->reason) {{ $userConnectionLog->reason }} @else N/A @endif

Connected At:

@if($userConnectionLog->connected_at) {{ $userConnectionLog->connected_at->format('M d, Y H:i:s') }} @else N/A @endif

Disconnected At:

@if($userConnectionLog->disconnected_at) {{ $userConnectionLog->disconnected_at->format('M d, Y H:i:s') }} @else N/A @endif

Uptime:

@if(isset($isStillActive) && $isStillActive && isset($liveSessionData) && $liveSessionData && isset($liveSessionData['uptime'])) @php // Use MikroTik's actual uptime string format (e.g., "1w5d16h15s") $uptimeStr = $liveSessionData['uptime']; @endphp {{ $uptimeStr }} (Live from MikroTik) @elseif(isset($isStillActive) && $isStillActive && $userConnectionLog->action == 'connect' && $userConnectionLog->connected_at) @php // Fallback: calculate from database timestamp $uptimeSeconds = now()->diffInSeconds($userConnectionLog->connected_at); $weeks = floor($uptimeSeconds / 604800); $days = floor(($uptimeSeconds % 604800) / 86400); $hours = floor(($uptimeSeconds % 86400) / 3600); $minutes = floor(($uptimeSeconds % 3600) / 60); $seconds = $uptimeSeconds % 60; $uptime = ''; if ($weeks > 0) $uptime .= $weeks . 'w'; if ($days > 0) $uptime .= $days . 'd'; if ($hours > 0) $uptime .= $hours . 'h'; if ($minutes > 0) $uptime .= $minutes . 'm'; if ($seconds > 0 || $uptime === '') $uptime .= $seconds . 's'; @endphp {{ $uptime }} (Live) @elseif($userConnectionLog->duration_seconds) {{ $userConnectionLog->formatted_duration }} @else N/A @endif

Duration:

@if($userConnectionLog->duration_seconds) {{ $userConnectionLog->formatted_duration }} @else N/A @endif

Created At:

{{ $userConnectionLog->created_at->format('M d, Y H:i:s') }}


Bytes In:

@if($userConnectionLog->bytes_in) {{ number_format($userConnectionLog->bytes_in) }} @else N/A @endif

Bytes Out:

@if($userConnectionLog->bytes_out) {{ number_format($userConnectionLog->bytes_out) }} @else N/A @endif

Packets In:

@if($userConnectionLog->packets_in) {{ number_format($userConnectionLog->packets_in) }} @else N/A @endif

Packets Out:

@if($userConnectionLog->packets_out) {{ number_format($userConnectionLog->packets_out) }} @else N/A @endif

@if($userConnectionLog->raw_data)
Raw Data:
{{ json_encode($userConnectionLog->raw_data, JSON_PRETTY_PRINT) }}
@endif

Connection History (Last 30 Days)

Bytes In/Out (Last 30 Days)

Data Usage & Connection Duration (Last 30 Days)

@endsection @section('scripts') @if(isset($isStillActive) && $isStillActive && isset($liveSessionData) && $liveSessionData && isset($liveSessionData['uptime'])) @elseif(isset($isStillActive) && $isStillActive && $userConnectionLog->action == 'connect' && $userConnectionLog->connected_at) @endif @endsection