@extends('layouts.app') @section('title', 'View Connection Log - ISP ERP System') @section('page-title', 'Connection Log Details') @section('content')
View connection log information
@if($lastConnected)
{{ $lastConnected->created_at->format('M d, Y') }}
{{ $lastConnected->created_at->format('H:i:s') }}
@else
N/A
@endif
@if($lastDisconnected)
{{ $lastDisconnected->created_at->format('M d, Y') }}
{{ $lastDisconnected->created_at->format('H:i:s') }}
@else
N/A
@endif
{{ $userConnectionLog->username }}
@if($userConnectionLog->action == 'connect') Connect @else Disconnect @endif
@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
@if($userConnectionLog->mikrotikServer) {{ $userConnectionLog->mikrotikServer->name }} ({{ $userConnectionLog->mikrotikServer->host }}) @else N/A @endif
@if($userConnectionLog->client) {{ $userConnectionLog->client->username }} - {{ $userConnectionLog->client->name ?? 'N/A' }} @else N/A @endif
@if($userConnectionLog->ip_address)
{{ $userConnectionLog->ip_address }}
@else
N/A
@endif
@if($userConnectionLog->mac_address)
{{ $userConnectionLog->mac_address }}
@else
N/A
@endif
@if($userConnectionLog->session_id)
{{ $userConnectionLog->session_id }}
@else
N/A
@endif
@if($userConnectionLog->interface) {{ $userConnectionLog->interface }} @else N/A @endif
@if($userConnectionLog->profile) {{ $userConnectionLog->profile }} @else N/A @endif
@if($userConnectionLog->reason) {{ $userConnectionLog->reason }} @else N/A @endif
@if($userConnectionLog->connected_at) {{ $userConnectionLog->connected_at->format('M d, Y H:i:s') }} @else N/A @endif
@if($userConnectionLog->disconnected_at) {{ $userConnectionLog->disconnected_at->format('M d, Y H:i:s') }} @else N/A @endif
@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
@if($userConnectionLog->duration_seconds) {{ $userConnectionLog->formatted_duration }} @else N/A @endif
{{ $userConnectionLog->created_at->format('M d, Y H:i:s') }}
@if($userConnectionLog->bytes_in) {{ number_format($userConnectionLog->bytes_in) }} @else N/A @endif
@if($userConnectionLog->bytes_out) {{ number_format($userConnectionLog->bytes_out) }} @else N/A @endif
@if($userConnectionLog->packets_in) {{ number_format($userConnectionLog->packets_in) }} @else N/A @endif
@if($userConnectionLog->packets_out) {{ number_format($userConnectionLog->packets_out) }} @else N/A @endif
{{ json_encode($userConnectionLog->raw_data, JSON_PRETTY_PRINT) }}